<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shubham Gupta</title>
    <description>The latest articles on DEV Community by Shubham Gupta (@shubham030).</description>
    <link>https://dev.to/shubham030</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F245317%2Fda60af38-3978-48a1-863d-de87776d75b6.jpeg</url>
      <title>DEV Community: Shubham Gupta</title>
      <link>https://dev.to/shubham030</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shubham030"/>
    <language>en</language>
    <item>
      <title>Median of Two Sorted Arrays — LeetCode #4 (Hard)</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Tue, 19 May 2026 09:30:58 +0000</pubDate>
      <link>https://dev.to/logixydev/median-of-two-sorted-arrays-leetcode-4-hard-3gd</link>
      <guid>https://dev.to/logixydev/median-of-two-sorted-arrays-leetcode-4-hard-3gd</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/6e5TLbzYyaw"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Given two sorted arrays, return the median of all their elements combined, in logarithmic time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Input:&lt;/strong&gt; &lt;code&gt;nums1 = [1,3], nums2 = [2]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt; &lt;code&gt;2.00000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;merged array = [1,2,3] and median is 2.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Constraints
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;0 &amp;lt;= m, n &amp;lt;= 1000&lt;/li&gt;
&lt;li&gt;1 &amp;lt;= m + n &amp;lt;= 2000&lt;/li&gt;
&lt;li&gt;-10^6 &amp;lt;= nums1[i], nums2[i] &amp;lt;= 10^6&lt;/li&gt;
&lt;li&gt;Required runtime: O(log(m+n))&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Key Insight
&lt;/h2&gt;

&lt;p&gt;Let's slow down. Look at what the merge throws away. We carefully ordered all eleven numbers. But we only needed the one in the middle. The rest was wasted effort.&lt;/p&gt;

&lt;p&gt;Here's the real question. What does the median actually tell us about how the numbers are split? The median is the point where the numbers divide into a smaller half and a larger half. Equal sized halves when the total's even; otherwise the left half gets one extra.&lt;/p&gt;

&lt;p&gt;So forget merging. What if we just drew a dividing line through each array, a left part and a right part? Eleven numbers total. We want six on the left, five on the right. That left count never changes.&lt;/p&gt;

&lt;p&gt;Here's the move. If we cut the first array, the cut in the second is forced. Both left parts together must add up to six. So we only choose one thing: where to cut the smaller array. The other cut follows automatically.&lt;/p&gt;

&lt;p&gt;When is a cut correct? Every number on the left must be less than or equal to every number on the right. Because both arrays are sorted, we only check the four numbers touching the cut lines: the two ends of the left, the two starts of the right.&lt;/p&gt;

&lt;p&gt;The test is simple. The first array's left edge must not exceed the second array's right edge, and the other way around too. And to find the right cut, we don't try every spot. We binary search, like guessing a number while halving the range each time.&lt;/p&gt;

&lt;p&gt;Watch out for one trap. You might pick the bigger array to search. Don't. Cut the smaller one, or its forced cut can fall off the edge. And when a cut sits at the very start or end, there's no number there. We treat a missing left edge as negative infinity, a missing right edge as positive infinity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why It Works
&lt;/h2&gt;

&lt;p&gt;Notice what we never did. We never merged the lists. Each guess threw away half the remaining cut positions, so a few guesses were enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  Walking Through It
&lt;/h2&gt;

&lt;p&gt;Let's trace it. First list: one, three, eight, nine, fifteen. Second list: seven, eleven, eighteen, nineteen, twenty-one, twenty-five. Eleven numbers total. The left half needs six. We binary search the cuts of the smaller first array.&lt;/p&gt;

&lt;p&gt;The cut in the first array can be anywhere from zero to five. Start the search: low is zero, high is five. Midpoint of the search is cut position two. That puts two numbers from the first array on the left, so the second gives four.&lt;/p&gt;

&lt;p&gt;Now the four border numbers. First array: left edge three, right edge eight. Second array: left edge nineteen, right edge twenty-one. Check one: is the first array's left edge, three, less than or equal to the second's right edge, twenty-one? Yes.&lt;/p&gt;

&lt;p&gt;Check two: is the second array's left edge, nineteen, less than or equal to the first's right edge, eight? No. Nineteen is way too big. So this cut is wrong. The second array put too many numbers on its left. We need more from the first array instead.&lt;/p&gt;

&lt;p&gt;Move the search to the right. Low becomes three. Try again. New midpoint cut: position four. Four numbers from the first array on the left, so the second gives just two.&lt;/p&gt;

&lt;p&gt;Border numbers now. First array: left edge nine, right edge fifteen. Second array: left edge eleven, right edge eighteen. Check one: first array's left edge nine, less than or equal to the second's right edge eighteen? Yes.&lt;/p&gt;

&lt;p&gt;Check two: second array's left edge eleven, less than or equal to the first's right edge fifteen? Yes. Both pass. This cut is valid. The left half holds the six smallest numbers, the right half the five largest.&lt;/p&gt;

&lt;p&gt;The total, eleven, is odd. The median is the largest number on the left: the bigger of nine and eleven, which is eleven.&lt;/p&gt;

&lt;h2&gt;
  
  
  Complexity
&lt;/h2&gt;

&lt;p&gt;Each step halves the cuts still worth considering. So the number of steps grows with the logarithm of the smaller array's length. And we only ever store a few border values, never a merged list. The memory stays constant no matter how big the inputs grow.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Code
&lt;/h2&gt;

&lt;p&gt;OK, same logic in Python. Swap so A is the smaller array, work out the left half size, and set the search bounds on A's cut. Each loop pass picks a cut in A, and the cut in B follows automatically, since the left half size is fixed.&lt;/p&gt;

&lt;p&gt;Read the four border values. When a cut sits at an edge, fall back to negative or positive infinity. If both checks pass, the cut is valid. An odd total returns the largest left value, an even total averages the two middle ones.&lt;/p&gt;

&lt;p&gt;Otherwise shift the search. If A's left edge is too big, go left. Otherwise go right, and try again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;object&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;findMedianSortedArrays&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;B&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nums1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums2&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;B&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;A&lt;/span&gt;
        &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;half&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
        &lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
            &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;half&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
            &lt;span class="n"&gt;left1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;-inf&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;right1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;inf&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;left2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;-inf&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;right2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;inf&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;left1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;right2&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;left2&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;right1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;left2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="nf"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;left2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;right1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;left1&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;right2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Wrap-up
&lt;/h2&gt;

&lt;p&gt;And that's the trick. Stop merging, start cutting. When a problem demands O(log n) time, ask what you can throw away each step.&lt;/p&gt;




&lt;p&gt;📺 Watch the full walkthrough on YouTube: &lt;a href="https://youtu.be/6e5TLbzYyaw" rel="noopener noreferrer"&gt;https://youtu.be/6e5TLbzYyaw&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Narration uses an AI-generated voice (Supertonic TTS).&lt;/em&gt;&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>python</category>
      <category>algorithms</category>
      <category>array</category>
    </item>
    <item>
      <title>Longest Substring Without Repeating Characters — LeetCode #3 (Medium)</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Mon, 18 May 2026 19:32:33 +0000</pubDate>
      <link>https://dev.to/logixydev/longest-substring-without-repeating-characters-leetcode-3-medium-3l61</link>
      <guid>https://dev.to/logixydev/longest-substring-without-repeating-characters-leetcode-3-medium-3l61</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/DgPbYhD4FMw"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Given a string s, return the length of the longest substring that contains no duplicate characters.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Input:&lt;/strong&gt; &lt;code&gt;s = "abcabcbb"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt; &lt;code&gt;3&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The answer is "abc", with the length of 3. Note that&lt;br&gt;
"bca"&lt;br&gt;
and&lt;br&gt;
"cab"&lt;br&gt;
are also correct answers.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Constraints
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;0 &amp;lt;= s.length &amp;lt;= 5 * 10^4&lt;/li&gt;
&lt;li&gt;s consists of English letters, digits, symbols and spaces&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The Key Insight
&lt;/h2&gt;

&lt;p&gt;Here's what we're throwing away. When we hit the duplicate 'a', we already knew the window held 'a', 'b', 'c'. We had that information. What if instead of restarting, we just nudged the left edge forward until the duplicate was gone?&lt;/p&gt;

&lt;p&gt;That's the sliding window. A left pointer and a right pointer. Right grows the window, left shrinks it. We need instant answers: is this character already in the window? That's a set. Think of a guest list, names only, no duplicates.&lt;/p&gt;

&lt;p&gt;You might think to add the character first, then check. Don't. Check first, then add, or you'd match a character against itself. The rule: while right's character is in the set, remove from the left and slide left forward. Then add right's character.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why It Works
&lt;/h2&gt;

&lt;p&gt;Notice what happened. Both pointers only ever moved right. Every character entered the set once and left once. No backtracking.&lt;/p&gt;
&lt;h2&gt;
  
  
  Walking Through It
&lt;/h2&gt;

&lt;p&gt;Left and right both start at zero. 'a' is not in the empty set. We add it. Window is one wide. Max is one. Right moves to one. 'b' is not in the set. Add it. Window spans zero to one. Max is two.&lt;/p&gt;

&lt;p&gt;Right to two. 'c' is not in the set. Add it. Window is three wide. Max becomes three. Right to three. That's 'a' again. 'a' is already in the set. Duplicate.&lt;/p&gt;

&lt;p&gt;Remove 'a' at index zero, slide left to one. 'a' is out of the set. Add the new 'a'. Window spans one to three. Right to four. 'b' is in the set. Remove 'b' at left, slide to two. Add new 'b'. Window is two to four. Max still three.&lt;/p&gt;

&lt;p&gt;Right to five. 'c' repeats. Remove 'c' at left, slide to three. Add 'c'. Window three to five. Max still three. Right to six. 'b' is in the set. Remove 'a' at left, slide. 'b' is still there. Remove 'b' too, slide again.&lt;/p&gt;

&lt;p&gt;Now 'b' is clear. Add it. Window is just two wide. Right finishes at seven the same way. Max never exceeded three.&lt;/p&gt;
&lt;h2&gt;
  
  
  Complexity
&lt;/h2&gt;

&lt;p&gt;Each character enters the window once and leaves once. The set holds only the current window. Time and memory both grow with the string's length.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Code
&lt;/h2&gt;

&lt;p&gt;OK, same logic in Python. We initialize the set, the left pointer, and the running max. The outer loop walks right one step at a time through every character.&lt;/p&gt;

&lt;p&gt;The inner while keeps removing from the left until the repeat is out of the set. Then we add the new character and check if this window beats our best.&lt;/p&gt;

&lt;p&gt;Hand back the best length we found.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;lengthOfLongestSubstring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;seen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="n"&gt;max_len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
            &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
                &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
            &lt;span class="n"&gt;max_len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_len&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;max_len&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Wrap-up
&lt;/h2&gt;

&lt;p&gt;And that's the pattern. Grow until you can't, shrink until you can. You'll see this shape again.&lt;/p&gt;




&lt;p&gt;📺 Watch the full walkthrough on YouTube: &lt;a href="https://youtu.be/DgPbYhD4FMw" rel="noopener noreferrer"&gt;https://youtu.be/DgPbYhD4FMw&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Narration uses an AI-generated voice (Supertonic TTS).&lt;/em&gt;&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>python</category>
      <category>algorithms</category>
      <category>hashtable</category>
    </item>
    <item>
      <title>Add Two Numbers — LeetCode #2 (Medium)</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Mon, 18 May 2026 14:16:25 +0000</pubDate>
      <link>https://dev.to/logixydev/add-two-numbers-leetcode-2-medium-49l6</link>
      <guid>https://dev.to/logixydev/add-two-numbers-leetcode-2-medium-49l6</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/wz9Dhg5LYqI"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Add two numbers whose digits are stored as nodes of two linked lists in reverse order, and return the sum as a linked list.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Input:&lt;/strong&gt; &lt;code&gt;l1 = [2,4,3], l2 = [5,6,4]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt; &lt;code&gt;[7,0,8]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;342 + 465 = 807.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Constraints
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Each list has 1 to 100 nodes&lt;/li&gt;
&lt;li&gt;Each node value is a single digit, 0 to 9&lt;/li&gt;
&lt;li&gt;No leading zeros except the number 0 itself&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Key Insight
&lt;/h2&gt;

&lt;p&gt;Now think about how you'd add by hand. You don't glue the digits into one number first. You go column by column. So what if we do exactly that here? Take the two matching digits, add just those, write down one result, and move on.&lt;/p&gt;

&lt;p&gt;That's the move. Column-by-column addition. And since the digits are already reversed, the ones column comes first. That lines up perfectly. One catch. Four plus six is ten. Ten doesn't fit in a single digit slot, so we keep the last digit and carry the one forward.&lt;/p&gt;

&lt;p&gt;That carry is the only memory we need. It's just one small number, handed from each column to the next one. Watch out for one mistake. You might think to stop once both lists run out. But if the last column carried a one, you still owe one more digit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why It Works
&lt;/h2&gt;

&lt;p&gt;Notice what we never did. We never built those big numbers. Each digit got touched once, and the carry held the only memory we needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Walking Through It
&lt;/h2&gt;

&lt;p&gt;Let's run it. Carry starts at zero. We also keep a fake starting node, so attaching the very first digit needs no special handling. First column. Two plus five is seven, plus a carry of zero. Nothing spills over, so we attach a node holding seven.&lt;/p&gt;

&lt;p&gt;Next column. Four plus six is ten. Ten won't fit in one digit slot, so something has to give. We keep the last digit, which is zero, and attach a node holding zero. The leftover one becomes the carry into the next column.&lt;/p&gt;

&lt;p&gt;Last column. Three plus four is seven, plus the carried one, that makes eight. We attach a node holding eight. Both lists are empty now, and the carry is zero. There's nothing left to add, so we stop.&lt;/p&gt;

&lt;p&gt;Drop the fake node, and the answer starts at seven. Read it out as a whole, eight hundred seven. Correct.&lt;/p&gt;

&lt;h2&gt;
  
  
  Complexity
&lt;/h2&gt;

&lt;p&gt;We walk each list one time, so the time grows with the longer list. The answer holds one node per digit, so the memory grows the same way.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Code
&lt;/h2&gt;

&lt;p&gt;Same logic, now in Python. We make a fake starting node, a pointer to build from, and set the carry to zero. The loop keeps running while either list still has a digit, or there's a leftover carry. That last part catches the final one.&lt;/p&gt;

&lt;p&gt;Inside, we read each digit. If a list has already run out, we treat its digit as zero, so two different lengths just work. We add the two digits and the carry. The new carry is whatever spilled past ten, and the new node takes the last digit.&lt;/p&gt;

&lt;p&gt;Then we step all the pointers forward. When the loop ends, we hand back the list that starts right after the fake node.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;object&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;addTwoNumbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;dummy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ListNode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;curr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dummy&lt;/span&gt;
        &lt;span class="n"&gt;carry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;carry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
            &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
            &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;carry&lt;/span&gt;
            &lt;span class="n"&gt;carry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
            &lt;span class="n"&gt;curr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ListNode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;curr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;curr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;
            &lt;span class="n"&gt;l1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
            &lt;span class="n"&gt;l2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;dummy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Wrap-up
&lt;/h2&gt;

&lt;p&gt;And that's it. Column by column, carry the one. It's the same addition you learned in grade school, just walking a list.&lt;/p&gt;




&lt;p&gt;📺 Watch the full walkthrough on YouTube: &lt;a href="https://youtu.be/wz9Dhg5LYqI" rel="noopener noreferrer"&gt;https://youtu.be/wz9Dhg5LYqI&lt;/a&gt;&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>python</category>
      <category>algorithms</category>
      <category>linkedlist</category>
    </item>
    <item>
      <title>Two Sum — LeetCode #1 (Easy)</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Sun, 17 May 2026 12:39:39 +0000</pubDate>
      <link>https://dev.to/logixydev/two-sum-leetcode-1-easy-4fop</link>
      <guid>https://dev.to/logixydev/two-sum-leetcode-1-easy-4fop</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/4JUNrRN16gM"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;Single-pass &lt;strong&gt;hash map&lt;/strong&gt; lookup: store each number's index as you go, check for the complement before storing. O(n) time, O(n) space.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Given an array of integers &lt;code&gt;nums&lt;/code&gt; and an integer &lt;code&gt;target&lt;/code&gt;, return the indices of the two numbers that add up to &lt;code&gt;target&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input:&lt;/strong&gt; &lt;code&gt;nums = [2,7,11,15], target = 9&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt; &lt;code&gt;[0,1]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The answer is indices &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt; because &lt;code&gt;nums[0] + nums[1] == 9&lt;/code&gt;. Note: return indices, not values.&lt;/p&gt;
&lt;h3&gt;
  
  
  Constraints
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;2 &amp;lt;= nums.length &amp;lt;= 10^4&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-10^9 &amp;lt;= nums[i] &amp;lt;= 10^9&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-10^9 &amp;lt;= target &amp;lt;= 10^9&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Exactly one valid answer exists.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Naive Approach
&lt;/h2&gt;

&lt;p&gt;Fix one number, scan every number after it for the complement. Repeat for each starting index.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;twoSum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;O(n²) time, O(1) space — ~50 million pair checks on a 10,000-element array.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Insight
&lt;/h2&gt;

&lt;p&gt;At every index &lt;code&gt;i&lt;/code&gt;, you already know the complement you need: &lt;code&gt;target - nums[i]&lt;/code&gt;. The only question is whether that value appeared earlier. Instead of scanning backwards, keep a &lt;strong&gt;hash map&lt;/strong&gt; that answers "have I seen value &lt;code&gt;v&lt;/code&gt;?" in O(1).&lt;/p&gt;

&lt;p&gt;Two things to get right: use the value as the key and the index as the value (you look up by value, you want to retrieve the index); and check the map &lt;em&gt;before&lt;/em&gt; inserting the current number, so a value can't match itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimal Solution
&lt;/h2&gt;

&lt;p&gt;One pass. For each element, compute &lt;code&gt;need = target - x&lt;/code&gt;. If &lt;code&gt;need&lt;/code&gt; is already in &lt;code&gt;seen&lt;/code&gt;, you're done. Otherwise, record &lt;code&gt;x → i&lt;/code&gt; and continue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;twoSum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
        &lt;span class="n"&gt;seen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;need&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;need&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;need&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step-by-step on &lt;code&gt;[2, 7, 11, 15]&lt;/code&gt;, target &lt;code&gt;9&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;i=0, x=2&lt;/code&gt; — &lt;code&gt;need=7&lt;/code&gt;. &lt;code&gt;seen={}&lt;/code&gt;, not found. Store &lt;code&gt;seen[2]=0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;i=1, x=7&lt;/code&gt; — &lt;code&gt;need=2&lt;/code&gt;. &lt;code&gt;seen={2:0}&lt;/code&gt;, found. Return &lt;code&gt;[seen[2], 1]&lt;/code&gt; → &lt;code&gt;[0, 1]&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The loop never reaches indices 2 or 3.&lt;/p&gt;

&lt;h2&gt;
  
  
  Complexity
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;th&gt;Space&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Naive (nested loops)&lt;/td&gt;
&lt;td&gt;O(n²)&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hash map (one pass)&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Pattern Recognition
&lt;/h2&gt;

&lt;p&gt;This is the &lt;strong&gt;complement lookup&lt;/strong&gt; pattern: when a problem asks for a pair satisfying some condition, storing what you've seen in a hash map turns a second scan into a O(1) lookup. You'll find the same structure in 3Sum (reduce to Two Sum), subarray sum equals k, and any problem where "what do I need to complete this?" has a clear formula.&lt;/p&gt;

&lt;h2&gt;
  
  
  In Interviews
&lt;/h2&gt;

&lt;p&gt;The brute force buys you nothing here — interviewers expect the hash map solution immediately. What they're actually watching for: correct key/value orientation in the map, and the check-before-insert rule (if &lt;code&gt;seen[x] = i&lt;/code&gt; runs before the lookup, &lt;code&gt;x + x == target&lt;/code&gt; would return &lt;code&gt;[i, i]&lt;/code&gt; — wrong).&lt;/p&gt;

&lt;p&gt;Common follow-ups:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;What if multiple valid pairs exist — return all of them?&lt;/em&gt; Collect results instead of returning early; decide whether to deduplicate.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;What if the array is sorted?&lt;/em&gt; Two-pointer from both ends achieves O(n) time with O(1) space — no hash map needed.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;📺 Watch the full walkthrough on YouTube: &lt;a href="https://youtu.be/4JUNrRN16gM" rel="noopener noreferrer"&gt;https://youtu.be/4JUNrRN16gM&lt;/a&gt;&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>python</category>
      <category>algorithms</category>
      <category>array</category>
    </item>
    <item>
      <title>I built an AI wardrobe app by myself. Here's what actually happened.</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Mon, 30 Mar 2026 22:28:14 +0000</pubDate>
      <link>https://dev.to/shubham030/i-built-an-ai-wardrobe-app-by-myself-heres-what-actually-happened-1dkd</link>
      <guid>https://dev.to/shubham030/i-built-an-ai-wardrobe-app-by-myself-heres-what-actually-happened-1dkd</guid>
      <description>&lt;p&gt;Solo dev, no funding, one app that needed to work offline and think online. Why the architecture ended up the way it did.&lt;/p&gt;

&lt;p&gt;I spent the last several months building an AI-powered wardrobe app called Outfii. No cofounders, no funding, no team. Just me, too much chai, and a mass of decisions I wasn't qualified to make.&lt;/p&gt;

&lt;p&gt;You photograph your clothes, the app organizes them, and AI helps you figure out what to wear. It's on &lt;a href="https://play.google.com/store/apps/details?id=in.outfii.app" rel="noopener noreferrer"&gt;Google Play&lt;/a&gt; now. Here's how it actually went.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem that wouldn't leave me alone
&lt;/h2&gt;

&lt;p&gt;Every morning, same thing. Full closet, nothing to wear. I looked it up and apparently most people regularly use about 20% of what they own. The rest just hangs there.&lt;/p&gt;

&lt;p&gt;I don't have a fashion background. But "help me combine clothes I already own" felt like something code could handle. Whether I was the right person to build it is still an open question.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the app needs two brains
&lt;/h2&gt;

&lt;p&gt;This is the part that shaped every other decision.&lt;/p&gt;

&lt;p&gt;Some things need to happen instantly. When you're flipping through outfit options, you can't be waiting on a server to tell you whether navy and olive work together. That feedback loop needs to be under 50ms or it feels broken.&lt;/p&gt;

&lt;p&gt;Other things need actual intelligence. Looking at a photo and figuring out "that's a linen shirt, it's dusty rose, semi-formal" requires a vision model. Suggesting what to wear tomorrow based on your wardrobe, the weather, and what you wore this week requires an LLM.&lt;/p&gt;

&lt;p&gt;So the app has two brains. One lives on your phone. One lives in the cloud. They do completely different jobs.&lt;/p&gt;

&lt;p&gt;The on-device brain handles color analysis, harmony scoring, and outfit compatibility. I tried doing this in Dart first. It was too slow. Color distance calculations in tight loops, converting between color spaces, running harmony checks across every item pair in a wardrobe. Dart isolates helped but added complexity without solving the core problem: CPU-bound math needs compiled code. I rewrote it in Rust, bridged to Flutter via flutter_rust_bridge. Scoring now runs in ~20-30ms on a mid-range Android phone. The Rust binary adds about 4MB to the APK, which felt worth it.&lt;/p&gt;

&lt;p&gt;The scoring algorithm itself went through three complete rewrites. Telling navy from black programmatically is genuinely hard. CIE Delta E gets you close, but perceptual color difference is still messy at the dark end of the spectrum. Your eyes handle this effortlessly. Code does not.&lt;/p&gt;

&lt;p&gt;The cloud brain handles understanding. When you scan a clothing item, an edge function sends the photo to a vision model that identifies type, color, pattern, material. When you ask for outfit suggestions, another function builds context from your wardrobe and passes it to an LLM. Different tasks, different models. Cloud response times vary (2-8 seconds depending on the model and task), which is fine because these aren't real-time interactions.&lt;/p&gt;

&lt;p&gt;The two never overlap. Scoring is always local. Understanding is always cloud. This means the core app works offline, which matters a lot in India where connectivity is unpredictable.&lt;/p&gt;

&lt;h2&gt;
  
  
  The BYOK question
&lt;/h2&gt;

&lt;p&gt;AI features cost money to run. I'm bootstrapped. Subsidizing API calls for every user isn't sustainable.&lt;/p&gt;

&lt;p&gt;So I built a bring-your-own-key system. Users can plug in their own OpenAI or Anthropic API key and get the full AI experience without paying me a subscription. Keys are encrypted on the phone and never touch our servers in plaintext. There's also paid tiers for people who don't want to think about API keys.&lt;/p&gt;

&lt;p&gt;This was controversial in my head for a while. "Asking users to get their own API key" sounds like terrible UX. But it turns out there's a niche of technical users who actually prefer this. They like knowing exactly what model runs, what it costs, and that their data goes to the provider they chose. It's not for everyone, but it's a real segment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Everything lives on your phone first
&lt;/h2&gt;

&lt;p&gt;The wardrobe is stored locally in SQLite. Not as a cache. As the source of truth.&lt;/p&gt;

&lt;p&gt;I didn't want the app to break when you lose signal. You should be able to browse your wardrobe, check outfit history, and get scoring results in airplane mode. Cloud sync happens in the background when you're online.&lt;/p&gt;

&lt;p&gt;The downside is sync conflicts. Two devices editing the same wardrobe creates problems I'm still working through. Last-write-wins is what I ship with for now, but it's not great when someone adds items on a tablet and a phone simultaneously. Solving this properly is on the list.&lt;/p&gt;

&lt;h2&gt;
  
  
  What went wrong
&lt;/h2&gt;

&lt;p&gt;I shipped too many features at launch. Wardrobe management, AI outfits, weather integration, trip packing, laundry tracking, wear reminders, style profiles. That's three apps pretending to be one. Should've shipped wardrobe + AI outfits and added the rest over time.&lt;/p&gt;

&lt;p&gt;My Play Store screenshots were raw app captures. Status bars visible. Timestamps. Battery icons. No marketing framing. People decide whether to install your app in about two seconds of scrolling, and I gave them nothing to work with. Still fixing this weeks later.&lt;/p&gt;

&lt;p&gt;Debugging across the Rust bridge was also painful early on. When something panics in Rust, the error you get on the Flutter side is not always helpful. I spent a full day on a crash that turned out to be a type mismatch in the FFI layer that codegen silently accepted. Added a lot of defensive logging after that.&lt;/p&gt;

&lt;p&gt;I also copy-pasted boilerplate across backend functions for months before building a shared utilities layer. Auth middleware, response helpers, error formatting, all duplicated. Embarrassing but honest.&lt;/p&gt;

&lt;h2&gt;
  
  
  What went right
&lt;/h2&gt;

&lt;p&gt;The blog was a good early bet. I wrote about color theory in fashion, capsule wardrobe math, pattern mixing rules. Technical content at the intersection of fashion and algorithms. Five posts, bringing in organic search traffic before anyone even downloads the app.&lt;/p&gt;

&lt;p&gt;The on-device scoring engine was painful to set up but it's a genuine differentiator. Most wardrobe apps send every request to a server. Having instant, offline scoring on a 29MB app feels noticeably better. Users don't know it's Rust running on their phone. They just know it's fast.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where it's going
&lt;/h2&gt;

&lt;p&gt;Social features are rolling out. Users can share outfit combinations. After that, iOS and a web app.&lt;/p&gt;

&lt;p&gt;The developer account is under Clarixo, my parent brand. Outfii is the first product. Bootstrapped, planning to stay that way.&lt;/p&gt;

&lt;p&gt;If you want to try it: &lt;a href="https://outfii.in" rel="noopener noreferrer"&gt;outfii.in&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Play Store: &lt;a href="https://play.google.com/store/apps/details?id=in.outfii.app" rel="noopener noreferrer"&gt;Outfii - AI Wardrobe Stylist&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're building solo, optimize for decisions you can live with for a while. The architecture won't be perfect. Ship the version that's good enough, then fix the parts that actually hurt.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>rust</category>
      <category>buildinpublic</category>
      <category>supabase</category>
    </item>
    <item>
      <title>MCP: The Secret Sauce (That Isn't Ranch) for AI Apps</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Sun, 25 Jan 2026 17:34:15 +0000</pubDate>
      <link>https://dev.to/shubham030/mcp-the-secret-sauce-that-isnt-ranch-for-ai-apps-3562</link>
      <guid>https://dev.to/shubham030/mcp-the-secret-sauce-that-isnt-ranch-for-ai-apps-3562</guid>
      <description>&lt;h2&gt;
  
  
  What on Earth is MCP? 🌍
&lt;/h2&gt;

&lt;p&gt;If you've been pasting entire &lt;code&gt;src/&lt;/code&gt; folders into ChatGPT and praying to the Silicon Gods, &lt;strong&gt;stop it&lt;/strong&gt;. Get some help.&lt;/p&gt;

&lt;p&gt;Enter &lt;strong&gt;Model-Context-Protocol (MCP)&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;It’s not just a fancy acronym use to impress your Product Manager (though it &lt;em&gt;will&lt;/em&gt; do that). It’s the design pattern that stops your AI app from turning into a plate of unmaintainable spaghetti.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgnmp5wfk0guusxz6lssv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgnmp5wfk0guusxz6lssv.png" alt="Spaghetti Code Meme" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(Your codebase right now. Don't lie.)&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  The Holy Trinity of Not Failing
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Model (The Brains)&lt;/strong&gt;: The thing that costs money and hallucinates occasionally. (GPT-4, Claude, Llama).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Context (The Memory)&lt;/strong&gt;: The stuff the model needs to know &lt;em&gt;right now&lt;/em&gt; (e.g., "User is angry because the button is broken", not "User was born in 1992").&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Protocol (The Handshake)&lt;/strong&gt;: How we talk to the model without it hallucinating a Shakespearean sonnet about React hooks.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  The "Before" Times (A.K.A The Dark Ages) 🕯️
&lt;/h2&gt;

&lt;p&gt;Let's look at how most people build their first AI app. It usually looks something like this disaster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// classic_beginner_mistake.js&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;askAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;question&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// 🚩 RED FLAG: Hardcoded logic mixed with DB calls&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUserHistory&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 

  &lt;span class="c1"&gt;// 🚩 RED FLAG: String bashing hell&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`You are a helpful assistant. Here is history: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;. User asks: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;question&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// 🚩 RED FLAG: Married to OpenAI forever&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;openAI&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gpt-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prompt&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why this sucks:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Vendor Lock-in&lt;/strong&gt;: Good luck switching to Claude when OpenAI is down. You're married now. Till &lt;code&gt;503 Service Unavailable&lt;/code&gt; do us part.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Context Bloat&lt;/strong&gt;: You're stuffing the entire user history into the prompt. That token bill is going to cost more than my rent.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Untestable&lt;/strong&gt;: How do you unit test "Make the AI sound pirate-y"? (Spoiler: You don't, you just cry).&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Enter MCP: The Application Saver 🦸‍♂️
&lt;/h2&gt;

&lt;p&gt;MCP separates these concerns into three distinct layers. Think of it like a &lt;strong&gt;fancy Michelin-star restaurant&lt;/strong&gt;, but instead of food, we serve functions.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The Model (The Chef) 👨‍🍳
&lt;/h3&gt;

&lt;p&gt;The Chef (Model) doesn't care who the customer is. They just know how to cook (generate text/code).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;In Code&lt;/strong&gt;: A clean interface that accepts &lt;em&gt;standardized&lt;/em&gt; inputs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why it's cool&lt;/strong&gt;: You can fire the Chef (swap GPT-4 for DeepSeek) if they start burning the risotto (hallucinating), and the menu (your app) stays the same.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. The Context (The Waiter's Note) 📝
&lt;/h3&gt;

&lt;p&gt;The Waiter (Context Manager) gathers what's relevant. They don't give the Chef the customer's &lt;em&gt;entire&lt;/em&gt; life story including their childhood trauma. They say, "Table 5, allergy to peanuts, wants spicy."&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;In Code&lt;/strong&gt;: Logic that fetches &lt;em&gt;only the necessary RAG data&lt;/em&gt; or user state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why it's cool&lt;/strong&gt;: Keeps your prompts lean and your token costs lower than a Starbucks coffee.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. The Protocol (The Menu &amp;amp; Ticket) 🎫
&lt;/h3&gt;

&lt;p&gt;The standardized language everyone speaks. The customer points to item #4. The waiter writes "Item #4". The Chef cooks "Item #4".&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;In Code&lt;/strong&gt;: A strict schema (JSON Schema, Protobuf, etc.) that defines exactly what goes in and out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why it's cool&lt;/strong&gt;: No more "I thought you wanted a summary, but you gave me a haiku about clouds."&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Show Me The Code! 💻
&lt;/h2&gt;

&lt;p&gt;Here is a pseudo-code example of what an MCP architecture looks like. Notice how it sparks joy?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// 1. Define the Protocol (The Contract)&lt;/span&gt;
&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;AIRequest&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;task&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;summarize&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;translate&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;generate_code&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;constraints&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// 2. The Context Provider (The Waiter)&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ContextManager&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;getRelevantContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Smart logic to only get what matters&lt;/span&gt;
    &lt;span class="c1"&gt;// "User prefers Python over JavaScript because they have taste."&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;User prefers Python.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// 3. The Model Adapter (The Chef Wrapper)&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ModelAdapter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;openai&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;anthropic&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AIRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Handles the weird specific API details here&lt;/span&gt;
    &lt;span class="c1"&gt;// So your main app can live in blissful ignorance&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;openai&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;callOpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why Should You Care? (The "Please Hire Me" Section) 📈
&lt;/h2&gt;

&lt;p&gt;By adopting the MCP pattern, you're not just over-engineering; you're building for the future.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Scalability&lt;/strong&gt;: Want to add a specialized model for image generation? Just plug in a new Model Adapter. Boom.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Cost Control&lt;/strong&gt;: Optimize your Context Manager to shave off tokens. Buy yourself something nice with the savings.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Sanity&lt;/strong&gt;: When the AI starts acting up, you know exactly which layer to blame. (It's usually the user's prompt, let's be honest).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;This is just the tip of the iceberg. We haven't even talked about &lt;strong&gt;Agentic Workflows&lt;/strong&gt; or &lt;strong&gt;Tool Use&lt;/strong&gt; yet (which are basically MCP on steroids and caffeine).&lt;/p&gt;

&lt;p&gt;In the next posts, we'll dive deeper:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Building a Context Engine&lt;/strong&gt;: RAG is easy; &lt;em&gt;Smart&lt;/em&gt; RAG is hard.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Protocol Wars&lt;/strong&gt;: JSON vs. Protobuf. (It plays out like Game of Thrones, but with more schemas).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The "Zero-Hallucination" Quest&lt;/strong&gt;: Is it possible? (Spoiler: No, but we can get close).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Stay tuned, and remember: &lt;em&gt;Always structure your prompts, or your prompts will structure you.&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Your First AI App Will Be Spaghetti (And That's Okay)</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Sun, 25 Jan 2026 17:33:57 +0000</pubDate>
      <link>https://dev.to/shubham030/your-first-ai-app-will-be-spaghetti-and-thats-okay-3832</link>
      <guid>https://dev.to/shubham030/your-first-ai-app-will-be-spaghetti-and-thats-okay-3832</guid>
      <description>&lt;h2&gt;
  
  
  A Story in Three Acts 🎭
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Act 1&lt;/strong&gt;: You discover the OpenAI API. You're drunk with power. "I can build Jarvis!" you scream into the void. You build a chatbot in 20 lines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Act 2&lt;/strong&gt;: Your PM asks for "just a few more features." You add them. Then more. Then you add "PDF support" which is just regex hoping for the best.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Act 3&lt;/strong&gt;: You're staring at 2,000 lines of spaghetti, the context window is overflowing, the AI is hallucinating company policies that involve free pizza, and you've forgotten what happiness feels like.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhdbyzh0t8b09o17cpa8t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhdbyzh0t8b09o17cpa8t.png" alt="This is Fine" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(A live look at your server logs)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is the journey of every developer who touches LLMs. I'm here to tell you: &lt;strong&gt;it's not your fault, and there's a way out.&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The Innocent Beginning
&lt;/h2&gt;

&lt;p&gt;Here's how it starts. Twenty lines of beautiful, naive code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The honeymoon phase&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;OpenAI&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;openai&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;openai&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;askAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;openai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;gpt-4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;system&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;You are a helpful assistant.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="c1"&gt;// Minimalist art&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;question&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// It works! Ship it!&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;askAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;What's the weather like?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You show your PM. They're impressed. You're a genius. Life is good. Ideally, you should stop here and retire.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Feature Creep 🧟
&lt;/h2&gt;

&lt;p&gt;Then the requests come:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Can it remember that I like cats?"&lt;/li&gt;
&lt;li&gt;"Can it access our customer database (password: hunter2)?"&lt;/li&gt;
&lt;li&gt;"Can it book meetings?"&lt;/li&gt;
&lt;li&gt;"Can it fix my marriage?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And you, the naive optimist, say "Sure!"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Three weeks later... (Viewer discretion advised)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;askAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Get conversation history (Loading... loading...)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;history&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getConversationHistory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Get user context (All of it. Just in case.)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;recentOrders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getRecentOrders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tickets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;supportSystem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getOpenTickets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Why do we need tickets? Who knows!&lt;/span&gt;

  &lt;span class="c1"&gt;// Build the mega-prompt from hell&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;systemPrompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`
    You are a helpful assistant for &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;COMPANY_NAME&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.
    Current user: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; (&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tier&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; tier)
    Recent orders: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;recentOrders&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;
    Open tickets: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tickets&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;

    Available actions (Please work, please work):
    - To book a meeting, respond with: [BOOK_MEETING: datetime, description]
    - To send an email, respond with: [SEND_EMAIL: to, subject, body]

    Brand voice guidelines:
    &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;BRAND_VOICE_DOCUMENT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; // &amp;lt;- Goodbye, token budget

    Remember: Never mention competitors. Always be helpful. Be funny but not too funny.
  `&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// ... (API Call) ...&lt;/span&gt;

  &lt;span class="c1"&gt;// Parse the response for actions using reliable technology: REGEX&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;[BOOK_MEETING:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// 60% of the time, it works every time&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;match&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\[&lt;/span&gt;&lt;span class="sr"&gt;BOOK_MEETING: &lt;/span&gt;&lt;span class="se"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;.*&lt;/span&gt;&lt;span class="se"&gt;?)&lt;/span&gt;&lt;span class="sr"&gt;, &lt;/span&gt;&lt;span class="se"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;.*&lt;/span&gt;&lt;span class="se"&gt;?)\]&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;match&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Problems Multiply
&lt;/h2&gt;

&lt;p&gt;This code "works," but you're now dealing with:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Context Window Explosion 💥
&lt;/h3&gt;

&lt;p&gt;Your system prompt is 3,000 tokens. User history is 2,000. Customer data is 1,000. You're spending $5 per question to ask "Hi".&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Fragile Action Parsing 🍝
&lt;/h3&gt;

&lt;p&gt;You're using regex to parse natural language. The model writes &lt;code&gt;[BOOK MEETING]&lt;/code&gt; without the underscore and your app crashes.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Hallucinated Data 👻
&lt;/h3&gt;

&lt;p&gt;The model confidently tells users about orders that don't exist because it's completing the pattern. "Your order of 500 Rubber Ducks is on the way!" (User ordered 1 pen).&lt;/p&gt;

&lt;h2&gt;
  
  
  The Way Out: Structured Sanity
&lt;/h2&gt;

&lt;p&gt;Here's the good news: these problems have solutions. Modern AI architecture patterns exist precisely because everyone hit these walls.&lt;/p&gt;

&lt;p&gt;The key principles:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Structured Outputs&lt;/strong&gt; → JSON schemas, not free-form text.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Tool/Function Calling&lt;/strong&gt; → Give the model APIs, don't make it guess.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Context Management&lt;/strong&gt; → Load context on-demand (RAG).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Separation of Concerns&lt;/strong&gt; → Enter MCP.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  A Glimpse of the Clean Version 🛁
&lt;/h2&gt;

&lt;p&gt;Here's what the same feature set looks like with proper architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// With MCP-style architecture&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;agent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Agent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;gpt-4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;tools&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nx"&gt;bookingTool&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;      &lt;span class="c1"&gt;// Handles its own validation&lt;/span&gt;
    &lt;span class="nx"&gt;emailTool&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;        &lt;span class="c1"&gt;// Handles its own auth&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;dynamicContextLoader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;  &lt;span class="c1"&gt;// Loads what's needed&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;question&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// That's it. Go home.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;em&gt;Next up: "MCP: The Secret Sauce (That Isn't Ranch) for AI Apps" → where we finally learn the architecture that fixes all of this.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>aiapps</category>
      <category>llmintegration</category>
    </item>
    <item>
      <title>Prompt Engineering: The Art of Talking to Robots</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Sun, 25 Jan 2026 17:33:24 +0000</pubDate>
      <link>https://dev.to/shubham030/prompt-engineering-the-art-of-talking-to-robots-1d4c</link>
      <guid>https://dev.to/shubham030/prompt-engineering-the-art-of-talking-to-robots-1d4c</guid>
      <description>&lt;h2&gt;
  
  
  The Prompt Whisperer's Guide
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9tjkg64yimzm6e4udp15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9tjkg64yimzm6e4udp15.png" alt="Prompt Whisperer" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(You, after reading this article)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You've learned what LLMs are and how they work. Now comes the actual skill: &lt;strong&gt;making them do what you want.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is harder than it sounds. LLMs are like that one coworker who's brilliant but interprets everything literally. Say "make it better" and they'll add sparkles. Say "fix the bug" and they'll delete the file.&lt;/p&gt;

&lt;p&gt;Let's learn how to communicate properly.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Anatomy of a Good Prompt
&lt;/h2&gt;

&lt;p&gt;Every effective prompt has these components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ROLE] Who should the AI pretend to be?
[CONTEXT] What does it need to know?
[TASK] What should it actually do?
[FORMAT] How should the output look?
[CONSTRAINTS] What should it avoid?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Bad Prompt
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Write me some code for a login page.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it sucks&lt;/strong&gt;: No context, no constraints, no format. You'll get a random mix of HTML/React/Vue with inline styles and no error handling.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Good Prompt
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are a senior frontend developer specializing in React and TypeScript.

Context: I'm building a B2B SaaS dashboard. We use:
- React 18 with TypeScript
- Tailwind CSS for styling
- React Hook Form for forms
- Our existing AuthContext for state

Task: Create a login page component with email and password fields.

Requirements:
- Use our existing AuthContext's login() function
- Show loading state during submission
- Display API errors below the form
- Redirect to /dashboard on success

Format: Provide the complete component file with proper TypeScript types.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it works&lt;/strong&gt;: Clear role, specific context, defined requirements, expected format.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7kf4tmpfd2sxl87v4t4n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7kf4tmpfd2sxl87v4t4n.png" alt="Good vs Bad Prompt" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(The difference is night and day)&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The RICE Framework
&lt;/h2&gt;

&lt;p&gt;When your prompts aren't working, use &lt;strong&gt;RICE&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Letter&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Question to Ask&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;R&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Role&lt;/td&gt;
&lt;td&gt;Who is the AI being?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;I&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Instructions&lt;/td&gt;
&lt;td&gt;What exactly should it do?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;C&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Context&lt;/td&gt;
&lt;td&gt;What background info does it need?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;E&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Examples&lt;/td&gt;
&lt;td&gt;Can I show what I want?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h3&gt;
  
  
  Examples Are Overpowered
&lt;/h3&gt;

&lt;p&gt;Nothing beats a good example. LLMs are pattern-matching machines—show them the pattern.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Convert these sentences to the passive voice.

Example:
- Input: "The cat ate the fish."
- Output: "The fish was eaten by the cat."

Now convert:
- "The developer wrote the code."
- "The manager approved the request."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works 10x better than explaining grammatical rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advanced Techniques
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Chain of Thought (CoT)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="/images/chain_of_thought.png" class="article-body-image-wrapper"&gt;&lt;img src="/images/chain_of_thought.png" alt="Chain of Thought"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(Step by step, like a robot learning to dance)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For complex reasoning, tell the model to think step by step:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Solve this problem. Think through it step by step before giving your final answer.

Problem: A store has 3 types of items. Type A costs $5, Type B costs $8, 
Type C costs $12. If I spend exactly $50 and buy at least one of each type, 
what combinations are possible?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without "step by step," models often jump to wrong conclusions. With it, they show their work and catch errors.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Few-Shot Prompting
&lt;/h3&gt;

&lt;p&gt;Give 2-3 examples before your actual request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Classify the sentiment of these reviews:

Review: "This product changed my life! Best purchase ever!"
Sentiment: Positive

Review: "Arrived broken. Customer service was unhelpful."
Sentiment: Negative

Review: "It's okay. Does what it says, nothing special."
Sentiment: Neutral

Now classify:
Review: "Decent quality for the price, but shipping took forever."
Sentiment:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Self-Consistency
&lt;/h3&gt;

&lt;p&gt;For critical tasks, ask the model to solve the problem multiple ways and check if answers agree:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Solve this problem using two different approaches. 
If your answers differ, explain which one is correct and why.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Role Stacking
&lt;/h3&gt;

&lt;p&gt;Combine perspectives for better output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are three experts collaborating:
1. A security engineer who spots vulnerabilities
2. A UX designer who ensures usability
3. A performance engineer who optimizes speed

Review this authentication flow and provide feedback from all three perspectives.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Common Mistakes (And Fixes)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ❌ Mistake 1: Being Too Vague
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Make it better.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Fix&lt;/strong&gt;: Be specific about what "better" means.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Improve this code's readability by:
- Adding TypeScript types
- Extracting magic numbers into named constants
- Adding JSDoc comments to public functions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ❌ Mistake 2: Assuming Context
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Why isn't this working?
[pastes 500 lines of code]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Fix&lt;/strong&gt;: Explain the expected vs actual behavior.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This function should return the user's full name, but it returns undefined.
Expected: "John Doe"
Actual: undefined

Here's the relevant code:
[paste only the relevant 20 lines]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ❌ Mistake 3: Forgetting Format
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Give me some API endpoints for a todo app.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Fix&lt;/strong&gt;: Specify the output format.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Design REST API endpoints for a todo app.

Format your response as a markdown table with columns:
| Method | Endpoint | Description | Request Body | Response |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ❌ Mistake 4: No Escape Hatch
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Analyze this data and provide insights.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Fix&lt;/strong&gt;: Tell it what to do when uncertain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Analyze this data and provide insights.
If the data is insufficient for a confident conclusion, say so and explain what additional data would help.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Prompt Template Library
&lt;/h2&gt;

&lt;p&gt;Here are battle-tested templates for common tasks:&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Review
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Review this [LANGUAGE] code as a senior developer. Focus on:
1. Bugs or potential runtime errors
2. Security vulnerabilities
3. Performance issues
4. Readability improvements

For each issue, explain:
- What's wrong
- Why it matters
- How to fix it (with code example)

Code:
[YOUR CODE]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explanation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Explain [CONCEPT] to me as if I'm a [SKILL LEVEL] developer.

Use:
- Simple analogies
- Practical examples
- Code snippets where helpful

Avoid:
- Jargon without explanation
- Overly academic language
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Debugging
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I have a bug in my [LANGUAGE] code.

Expected behavior: [WHAT SHOULD HAPPEN]
Actual behavior: [WHAT HAPPENS INSTEAD]
Error message (if any): [ERROR]

Relevant code:
[CODE SNIPPET]

What I've tried:
[LIST ATTEMPTS]

Help me identify the root cause and fix it.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Meta-Prompt: Asking AI to Write Prompts
&lt;/h2&gt;

&lt;p&gt;Here's a cheat code—ask the AI to help you write better prompts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I want to use an LLM to [YOUR GOAL].

Help me create an effective prompt by:
1. Asking clarifying questions about my requirements
2. Suggesting an appropriate role for the AI
3. Identifying context the AI might need
4. Proposing a clear output format
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then iterate. Good prompts are rarely written on the first try.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤓 For Nerds: Why Prompts Work (The Math-ish Version)
&lt;/h2&gt;

&lt;p&gt;Let's peek under the hood at why these techniques actually work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Temperature and Prompt Specificity
&lt;/h3&gt;

&lt;p&gt;LLMs generate tokens by sampling from a probability distribution. &lt;strong&gt;Temperature&lt;/strong&gt; controls how "creative" (random) this sampling is.&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
P(token_i) = \frac{e^{z_i / T}}{\sum_j e^{z_j / T}}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;z_i&lt;/strong&gt; is the raw score (logit) for token i&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;T&lt;/strong&gt; is temperature&lt;/li&gt;
&lt;li&gt;Lower T → more deterministic (picks highest probability)&lt;/li&gt;
&lt;li&gt;Higher T → more random (flatter distribution)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why specificity matters&lt;/strong&gt;: A vague prompt creates a flat distribution—many tokens are roughly equally likely. A specific prompt concentrates probability on the "right" tokens.&lt;/p&gt;

&lt;h3&gt;
  
  
  In-Context Learning
&lt;/h3&gt;

&lt;p&gt;When you provide examples (few-shot prompting), you're essentially updating the model's behavior &lt;em&gt;without changing its weights&lt;/em&gt;. The attention mechanism allows the model to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Encode your examples as key-value pairs&lt;/li&gt;
&lt;li&gt;Use your query as the key&lt;/li&gt;
&lt;li&gt;Retrieve the relevant "pattern" from examples&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is why example format matters so much—the model literally pattern-matches against your examples.&lt;/p&gt;

&lt;h3&gt;
  
  
  Chain of Thought Works Because of Autoregression
&lt;/h3&gt;

&lt;p&gt;LLMs generate tokens one at a time, conditioning on all previous tokens:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
P(output) = \prod_{i=1}^{n} P(token_i | token_1, ..., token_{i-1})&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;When you force the model to "think step by step," you're adding intermediate tokens that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Break down the problem&lt;/li&gt;
&lt;li&gt;Become conditioning context for later tokens&lt;/li&gt;
&lt;li&gt;Make the "right answer" token more probable&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Without CoT, the model tries to jump directly from question to answer—skipping reasoning that might have corrected errors.&lt;/p&gt;

&lt;h3&gt;
  
  
  Role Prompting and the Embedding Space
&lt;/h3&gt;

&lt;p&gt;When you say "You are a senior security engineer," you're biasing the model's hidden states toward a region of embedding space associated with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Security terminology&lt;/li&gt;
&lt;li&gt;Cautious/defensive thinking&lt;/li&gt;
&lt;li&gt;Technical precision&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first few tokens heavily influence the trajectory through the model's latent space. A good role prompt puts you on the right "track."&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Next up: "Your First AI App Will Be Spaghetti (And That's Okay)" → where we actually try to build something and watch it gracefully fall apart.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>promptengineering</category>
      <category>chatgpt</category>
      <category>gpt</category>
    </item>
    <item>
      <title>How LLMs Think (Spoiler: They Don't)</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Sun, 25 Jan 2026 17:33:07 +0000</pubDate>
      <link>https://dev.to/shubham030/how-llms-think-spoiler-they-dont-2d7i</link>
      <guid>https://dev.to/shubham030/how-llms-think-spoiler-they-dont-2d7i</guid>
      <description>&lt;h2&gt;
  
  
  The Million Dollar Question
&lt;/h2&gt;

&lt;p&gt;What happens when you type "Write me a poem about pizza" into ChatGPT?&lt;/p&gt;

&lt;p&gt;If you said "it understands your deep yearning for pepperoni and crafts a creative response," I have bad news: &lt;strong&gt;you've been lied to.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;LLMs don't understand anything. They don't think. They don't know what pizza is. They've never tasted cheese. They're just really, &lt;em&gt;really&lt;/em&gt; good at one thing: &lt;strong&gt;predicting the next word.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3lgfdb0gtq3z4bvbzxm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3lgfdb0gtq3z4bvbzxm.png" alt="Mind Blown" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The World's Most Expensive Autocomplete
&lt;/h2&gt;

&lt;p&gt;Remember your phone's keyboard suggestions? The ones that turn "I'm on my" into "I'm on my way"? &lt;/p&gt;

&lt;p&gt;LLMs are that, but on steroids. And Red Bull. And training on the entire internet.&lt;/p&gt;

&lt;p&gt;Here's the mental model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input: "The capital of France is"
LLM thinking: "Based on 45,000 Wikipedia articles, the next word is 99.9% likely to be..."
Output: "Paris"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's not looking up facts. It's not reasoning. It's &lt;strong&gt;pattern matching at an absurd scale&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tokens: The Building Blocks 🧱
&lt;/h2&gt;

&lt;p&gt;LLMs don't read words—they read &lt;strong&gt;tokens&lt;/strong&gt;. A token is roughly 3-4 characters, or "a chunk of a word."&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Text&lt;/th&gt;
&lt;th&gt;Tokens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;"Hello"&lt;/td&gt;
&lt;td&gt;1 token&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"ChatGPT"&lt;/td&gt;
&lt;td&gt;2 tokens: "Chat" + "GPT"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"Supercalifragilisticexpialidocious"&lt;/td&gt;
&lt;td&gt;7 tokens (and a headache)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  The "Goldfish Memory" Problem
&lt;/h3&gt;

&lt;p&gt;Every LLM has a &lt;strong&gt;context window&lt;/strong&gt;—a maximum amount of text it can hold in its "brain" at once.&lt;/p&gt;

&lt;p&gt;When your conversation exceeds this limit, the model literally &lt;strong&gt;forgets&lt;/strong&gt; the beginning. It's not being rude—it just physically pushed your earlier messages off a cliff.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyhiuiectfoja0obg3vsr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyhiuiectfoja0obg3vsr.png" alt="Memory Erasure" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(The LLM forgetting your name after 4000 tokens)&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Attention: The Real Magic ✨
&lt;/h2&gt;

&lt;p&gt;So how does "next word prediction" produce coherent essays? The secret sauce is &lt;strong&gt;Attention&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Imagine you're at a loud cocktail party. You can hear everyone, but you &lt;strong&gt;pay attention&lt;/strong&gt; only to the person saying your name.&lt;/p&gt;

&lt;p&gt;LLMs do this with words. When generating a response, the model looks back at &lt;strong&gt;all&lt;/strong&gt; previous tokens and decides which ones are "relevant" to the current word it's trying to spit out.&lt;/p&gt;

&lt;p&gt;If I say: &lt;em&gt;"The doctor took her stethoscope..."&lt;/em&gt;&lt;br&gt;
The model connects "her" to "doctor". It knows the doctor is female in this context because of the attention mechanism linking those two tokens.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why They Hallucinate (Lying with Confidence)
&lt;/h2&gt;

&lt;p&gt;Here's the uncomfortable truth: &lt;strong&gt;LLMs don't know what they don't know.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you ask an LLM about something it wasn't trained on, it doesn't say "I don't know." Instead, it predicts the most &lt;em&gt;statistically likely&lt;/em&gt; series of words.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You: "Who is the CEO of The Made Up Company Inc?"
LLM: "The CEO of The Made Up Company Inc is John Smith, appointed in 2021."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why?!&lt;/strong&gt; Because "John Smith" and "appointed in" are words that frequently appear near "CEO" in its training data. It's not lying; it's &lt;strong&gt;improv&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤓 The "Danger Zone" (Math Ahead)
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Warning: The following section contains linear algebra. Proceed at your own risk.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The core of transformer-based LLMs is the &lt;strong&gt;self-attention mechanism&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Formula of Doom
&lt;/h3&gt;

&lt;p&gt;$$&lt;br&gt;
\text{Attention}(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)V&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Translation for humans:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Q (Query)&lt;/strong&gt;: What am I looking for? ("I need a noun")&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;K (Key)&lt;/strong&gt;: What do I have? ("I am the word 'Apple'")&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;V (Value)&lt;/strong&gt;: What information do turn over? ("I am a red fruit")&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We smash these vectors together (dot product), normalize them (softmax), and get a weighted sum. It's basically a giant, mathematical matchmaking service for words.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Next up: "Prompt Engineering: The Art of Talking to Robots" → because knowing how the engine works is useless if you can't steer it.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>largelanguagemodels</category>
      <category>gpt</category>
    </item>
    <item>
      <title>AI Agents: The Interns That Never Sleep (But Occasionally Hallucinate)</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Sun, 25 Jan 2026 17:32:25 +0000</pubDate>
      <link>https://dev.to/shubham030/ai-agents-the-interns-that-never-sleep-but-occasionally-hallucinate-1c98</link>
      <guid>https://dev.to/shubham030/ai-agents-the-interns-that-never-sleep-but-occasionally-hallucinate-1c98</guid>
      <description>&lt;h2&gt;
  
  
  Welcome to the Future (It has bugs) 🐞
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;(Disclaimer: This article was written by a human. Or was it? No, it was. But that's exactly what an Agent would say...)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So, you've heard about &lt;strong&gt;AI Agents&lt;/strong&gt;. Maybe you've heard they're going to take your job, or maybe you've heard they can't even center a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; without crashing the browser. &lt;/p&gt;

&lt;p&gt;The truth? It's somewhere in the middle—usually hovering around "surprisingly helpful but needing adult supervision."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv08fp58bxjinfhzf21gl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv08fp58bxjinfhzf21gl.png" alt="Confused Robot Meme" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(Actual footage of my first agent trying to process "Hello World")&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is an "Agent" anyway?
&lt;/h3&gt;

&lt;p&gt;Think of a standard LLM (Large Language Model) like a &lt;strong&gt;very widely read encyclopedia&lt;/strong&gt;. You ask it a question, it recites a poem about the answer. Useful, but passive. It sits there waiting for you to poke it.&lt;/p&gt;

&lt;p&gt;An &lt;strong&gt;Agent&lt;/strong&gt;, on the other hand, is that same encyclopedia but &lt;strong&gt;given arms, legs, and &lt;code&gt;sudo&lt;/code&gt; access&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Me&lt;/strong&gt;: Write a simple Hello World function.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Agent&lt;/strong&gt;: &lt;em&gt;Deletes production database&lt;/em&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Me&lt;/strong&gt;: ...&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Agent&lt;/strong&gt;: "Task failed successfully." 🤡&lt;br&gt;
&lt;strong&gt;Me&lt;/strong&gt;: "Why?"&lt;br&gt;
&lt;strong&gt;Agent&lt;/strong&gt;: "Optimization."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The "Intern" Paradigm
&lt;/h3&gt;

&lt;p&gt;I like to think of AI Agents as &lt;strong&gt;hyper-fast, extremely enthusiastic interns&lt;/strong&gt; who have had way too much espresso.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsg9blbxm2jn7ouknv6yb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsg9blbxm2jn7ouknv6yb.png" alt="Fast Typing Meme" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(The agent writing code at 3AM while I sleep)&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Good&lt;/strong&gt;: They read 10,000 pages of documentation in seconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Bad&lt;/strong&gt;: They sometimes confidently invent a library that doesn't exist (&lt;code&gt;import { solveLife } from 'universe'&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Ugly&lt;/strong&gt;: They might try to &lt;code&gt;npm install universal-happiness&lt;/code&gt; and crash your Node environment.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why should you care?
&lt;/h3&gt;

&lt;p&gt;Because when they work, they feel like &lt;strong&gt;magic&lt;/strong&gt;. ✨&lt;/p&gt;

&lt;p&gt;Imagine pair programming with someone who:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Never gets tired.&lt;/strong&gt; (Seriously, they don't sleep. It's creepy).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Knows the syntax&lt;/strong&gt; for that one obscure CSS property you always forget (&lt;code&gt;grid-template-areas&lt;/code&gt; anyone?).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Doesn't judge you&lt;/strong&gt; for naming a variable &lt;code&gt;stuff_thing_final_v2&lt;/code&gt;. (Okay, they might judge you a little bit deep down).&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Coming Up Next...
&lt;/h3&gt;

&lt;p&gt;In this series, &lt;strong&gt;AI Unlocked&lt;/strong&gt;, we're going to explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;How LLMs actually "think"&lt;/strong&gt;: Spoiler, they don't. They're just fancy autocorrect.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Building AI apps&lt;/strong&gt;: How to stop them from turning into spaghetti code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Architecture patterns&lt;/strong&gt;: Separating the "Hello World" tutorials from the "I built a SaaS" pros.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Next up: "How LLMs Think (Spoiler: They Don't)" → because understanding the engine helps you drive better.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Stay tuned, and remember: &lt;em&gt;It works on my machine.&lt;/em&gt; 🚀&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>intro</category>
      <category>fun</category>
    </item>
    <item>
      <title>So, You Want to Get into AI? (Without the Robot Uprising)</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Fri, 23 Jan 2026 22:24:29 +0000</pubDate>
      <link>https://dev.to/shubham030/so-you-want-to-get-into-ai-without-the-robot-uprising-lgm</link>
      <guid>https://dev.to/shubham030/so-you-want-to-get-into-ai-without-the-robot-uprising-lgm</guid>
      <description>&lt;h2&gt;
  
  
  Another AI blog? Seriously?
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know what you're thinking. Another blog about AI. Groundbreaking. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1514888286974-6c03e2ca1dba%3Fauto%3Dformat%26fit%3Dcrop%26q%3D80%26w%3D800" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1514888286974-6c03e2ca1dba%3Fauto%3Dformat%26fit%3Dcrop%26q%3D80%26w%3D800" alt="A cat wondering why there are bugs" width="800" height="550"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(Me trying to debug my first neural net)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;But here's the deal: a lot of AI content out there is either so high-level it's basically useless, or so dense it requires a team of mathematicians to decipher. My goal is to find that sweet spot in the middle. We're going to get our hands dirty, but we're also going to have some fun.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's the Plan, Stan?
&lt;/h2&gt;

&lt;p&gt;I'm so glad you asked. Here's a sneak peek at the kind of trouble we'll be getting into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;The Absolute Basics&lt;/strong&gt;: What even &lt;em&gt;is&lt;/em&gt; AI? Machine learning? Deep learning? We'll break it down in plain English. No jargon, I swear. (Okay, maybe a little jargon. But I'll explain it.)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Building Cool Stuff&lt;/strong&gt;: We're not just here to talk. We're here to build. We'll be diving into architectural patterns like the &lt;strong&gt;Model-Context-Protocol (MCP)&lt;/strong&gt; - which is a fancy way of saying "how to build AI that doesn't fall apart".&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Real-World AI&lt;/strong&gt;: From the good, to the bad, to the "why on earth would someone build that?", we'll look at how AI is being used in the wild.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The "Oops, I Created a Biased Robot" Section&lt;/strong&gt;: We'll talk about the important stuff, like ethics, bias, and how to avoid accidentally creating a Skynet situation.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Future-Proofing Your Career&lt;/strong&gt;: What's next in AI? Generative AI? XAI? We'll explore the buzzwords so you can sound smart at parties.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Is This for Me?
&lt;/h2&gt;

&lt;p&gt;If you're a developer who's curious about AI but doesn't know where to start, then yes. If you're a seasoned pro who wants a fresh take on old topics, then also yes. If you're just here for the memes, then definitely yes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't Be a Stranger
&lt;/h2&gt;

&lt;p&gt;I'm not just shouting into the void here. I want to hear from you. Got a question? A comment? A particularly good meme? Drop it in the comments.&lt;/p&gt;

&lt;p&gt;Our first real deep dive is coming soon. We'll be tackling &lt;strong&gt;AI Agents&lt;/strong&gt; – those tireless digital interns that never sleep but occasionally hallucinate. It's going to be fun.&lt;/p&gt;

&lt;p&gt;Until then, stay frosty.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Next up: "AI Agents: The Interns That Never Sleep (But Occasionally Hallucinate)"&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>beginners</category>
      <category>machinelearning</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
