<?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: Irshad's Intersection</title>
    <description>The latest articles on DEV Community by Irshad's Intersection (@irshads_intersection).</description>
    <link>https://dev.to/irshads_intersection</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%2F3842460%2F789d636f-a916-46ec-a013-7aee3cfe47ba.png</url>
      <title>DEV Community: Irshad's Intersection</title>
      <link>https://dev.to/irshads_intersection</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/irshads_intersection"/>
    <language>en</language>
    <item>
      <title>HTTP Request Lifecycle Explained — What Really Happens When You Hit Enter</title>
      <dc:creator>Irshad's Intersection</dc:creator>
      <pubDate>Tue, 31 Mar 2026 12:46:24 +0000</pubDate>
      <link>https://dev.to/irshads_intersection/http-request-lifecycle-explained-what-really-happens-when-you-hit-enter-4c9</link>
      <guid>https://dev.to/irshads_intersection/http-request-lifecycle-explained-what-really-happens-when-you-hit-enter-4c9</guid>
      <description>&lt;p&gt;You type &lt;a href="https://google.com" rel="noopener noreferrer"&gt;https://google.com&lt;/a&gt; into your browser and press Enter.&lt;/p&gt;

&lt;p&gt;In about 200 milliseconds, a fully rendered page appears.&lt;/p&gt;

&lt;p&gt;But what actually happened in those 200 milliseconds?&lt;/p&gt;

&lt;p&gt;Most developers — even experienced ones — have a vague idea. ‘DNS happens, then TCP, then… HTTP stuff.’ But if you’re building backends, designing APIs, debugging slow responses, or preparing for system design interviews, ‘vague’ is not good enough.&lt;/p&gt;

&lt;p&gt;In this post, we’re going to trace every single thing that happens — from the moment you press Enter to the moment the response arrives — explained in plain language with real examples and actual HTTP messages.&lt;/p&gt;

&lt;p&gt;Let’s go.&lt;/p&gt;

&lt;p&gt;The 7 Stages at a Glance&lt;br&gt;
Before we dive deep into each stage, here’s the full picture:&lt;/p&gt;

&lt;p&gt;Stage   What Happens    Who Does It&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;URL Parsing  Browser breaks down the URL into parts  Browser&lt;/li&gt;
&lt;li&gt;DNS Lookup   Domain name is resolved to an IP address    OS + DNS Servers&lt;/li&gt;
&lt;li&gt;TCP Handshake    A reliable connection is established    Client + Server&lt;/li&gt;
&lt;li&gt;TLS Handshake    Connection is encrypted (HTTPS only)    Client + Server&lt;/li&gt;
&lt;li&gt;HTTP Request Client sends the actual request message Browser / HTTP Client&lt;/li&gt;
&lt;li&gt;Server Processing    Server receives, routes, processes, and responds    Your Backend Code&lt;/li&gt;
&lt;li&gt;Connection End   Connection is closed or kept alive for future requests  Client + Server
💡  As a backend developer, you directly control Stage 6 (Server Processing). But understanding Stages 1-5 is what lets you diagnose slow APIs, set correct headers, design better systems, and answer senior-level interview questions.
Stage 1  URL Parsing&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Before anything goes over the network, the browser breaks down what you typed into structured parts.&lt;/p&gt;

&lt;p&gt;Take this URL: &lt;a href="https://api.example.com:443/users/42?format=json#profile" rel="noopener noreferrer"&gt;https://api.example.com:443/users/42?format=json#profile&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Part    Value   What it means&lt;br&gt;
Scheme  https   Use HTTPS protocol (encrypted HTTP)&lt;br&gt;
Host    api.example.com The domain name to connect to&lt;br&gt;
Port    443 Port number (443 is default for HTTPS, 80 for HTTP)&lt;br&gt;
Path    /users/42   The specific resource being requested&lt;br&gt;
Query   ?format=json    Additional parameters passed to the server&lt;br&gt;
Fragment    #profile    Client-side anchor — never sent to the server&lt;br&gt;
🔑  The fragment (#profile) is NEVER sent to the server. It is processed entirely by the browser. Your backend will never see it. This is a classic interview gotcha.&lt;br&gt;
The browser also checks a few things at this stage:&lt;/p&gt;

&lt;p&gt;Is this a valid URL format?&lt;br&gt;
Is the scheme supported (http, https, ftp, etc.)?&lt;br&gt;
If no port is specified — assume 80 for HTTP, 443 for HTTPS&lt;br&gt;
Encode any special characters in the path or query using percent-encoding (spaces become %20, etc.)&lt;br&gt;
Stage 2  DNS Lookup — Translating Domain to IP Address&lt;/p&gt;

&lt;p&gt;Your computer does not know where ‘api.example.com’ is. It only understands IP addresses — numerical addresses like 142.250.80.46. DNS (Domain Name System) is the phonebook that translates one to the other.&lt;/p&gt;

&lt;p&gt;The DNS Resolution Chain&lt;br&gt;
DNS lookup does not happen in one step. It’s a chain of queries, each one more specific than the last:&lt;/p&gt;

&lt;p&gt;Step    Where it checks What it does&lt;br&gt;
1   Browser DNS cache   Did I recently look up this domain? Use cached IP.&lt;br&gt;
2   OS DNS cache    Has this machine looked it up? Check /etc/hosts and OS cache.&lt;br&gt;
3   Router / ISP DNS    Ask the local DNS resolver (usually your router or ISP).&lt;br&gt;
4   Root DNS servers    13 root servers worldwide. Returns address of TLD nameserver.&lt;br&gt;
5   TLD nameserver (.com, .in)  Returns address of the domain’s authoritative nameserver.&lt;br&gt;
6   Authoritative nameserver    Returns the actual IP address for the domain.&lt;/p&gt;

&lt;p&gt;READ FULL POST: &lt;a href="https://dailydevnotes.in/slug-http-request-lifecycle-explained-backend/" rel="noopener noreferrer"&gt;https://dailydevnotes.in/slug-http-request-lifecycle-explained-backend/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>api</category>
    </item>
    <item>
      <title>LeetCode 11 — Container With Most Water | Full Solution Explained</title>
      <dc:creator>Irshad's Intersection</dc:creator>
      <pubDate>Sat, 28 Mar 2026 14:16:45 +0000</pubDate>
      <link>https://dev.to/irshads_intersection/leetcode-11-container-with-most-water-full-solution-explained-4o5l</link>
      <guid>https://dev.to/irshads_intersection/leetcode-11-container-with-most-water-full-solution-explained-4o5l</guid>
      <description>&lt;p&gt;Difficulty  Pattern Asked At    LeetCode Link&lt;br&gt;
Medium  Two Pointers (Opposite Ends)    Amazon, Google, Microsoft, Bloomberg, Apple leetcode.com/problems/container-with-most-water&lt;br&gt;
📌  This is part of the Two Pointers series on Daily Dev Notes. If you haven’t read the Two Pointers pattern guide yet, start there — it will make this solution much easier to understand.&lt;br&gt;
This problem has a sneaky quality to it.&lt;/p&gt;

&lt;p&gt;When you first read it, it looks like a geometry problem. But once you see the right way to think about it, it becomes a clean, elegant Two Pointers problem that solves in a single pass.&lt;/p&gt;

&lt;p&gt;The hard part is not the code — the code is just 10 lines. The hard part is building the intuition for why the Two Pointers approach is correct. That’s what this post focuses on.&lt;/p&gt;

&lt;p&gt;Let’s go from scratch.&lt;/p&gt;

&lt;p&gt;The Problem Statement&lt;br&gt;
You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the i-th line are at (i, 0) and (i, height[i]).&lt;/p&gt;

&lt;p&gt;Find two lines that together with the x-axis form a container that holds the most water. Return the maximum amount of water a container can store.&lt;/p&gt;

&lt;p&gt;Note: You cannot slant the container.&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;Example 1:&lt;br&gt;
  Input:  height = [1, 8, 6, 2, 5, 4, 8, 3, 7]&lt;br&gt;
  Output: 49&lt;br&gt;
  Why:    Lines at index 1 (height=8) and index 8 (height=7)&lt;br&gt;
          Width  = 8 - 1 = 7&lt;br&gt;
          Height = min(8, 7) = 7&lt;br&gt;
          Area   = 7 × 7 = 49&lt;/p&gt;

&lt;p&gt;Example 2:&lt;br&gt;
  Input:  height = [1, 1]&lt;br&gt;
  Output: 1&lt;br&gt;
  Why:    Only two lines. Width=1, Height=min(1,1)=1, Area=1&lt;br&gt;
Understanding the Area Formula&lt;br&gt;
Before jumping into the solution, let’s make sure the area calculation is completely clear.&lt;/p&gt;

&lt;p&gt;If you pick two lines at positions i and j (where i &amp;lt; j), the water they can hold is:&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;Area = width × height&lt;br&gt;
     = (j - i) × min(height[i], height[j])&lt;/p&gt;

&lt;p&gt;The height is min() of the two lines because water spills&lt;br&gt;
over the shorter one — you can never fill above the shorter line.&lt;br&gt;
💡  The area is always limited by the SHORTER line. This single observation is the entire key to understanding why the Two Pointers approach works.&lt;br&gt;
Step 1 — Brute Force Approach&lt;br&gt;
As always, let’s start with the obvious solution. Check every possible pair of lines and track the maximum area.&lt;/p&gt;

&lt;p&gt;Brute Force&lt;/p&gt;

&lt;p&gt;// Brute Force — O(n²) time, O(1) space&lt;br&gt;
int maxArea(vector&amp;amp; height) {&lt;br&gt;
    int maxWater = 0;&lt;br&gt;
    int n = height.size();&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (int i = 0; i &amp;lt; n; i++) {
    for (int j = i + 1; j &amp;lt; n; j++) {
        int width  = j - i;
        int h      = min(height[i], height[j]);
        int area   = width * h;
        maxWater   = max(maxWater, area);
    }
}
return maxWater;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
Metric  Brute Force Impact&lt;br&gt;
Time Complexity O(n²)  Two nested loops — for n=10,000, that’s 100 million operations&lt;br&gt;
Space Complexity    O(1)    Fine — no extra data structures&lt;br&gt;
LeetCode Result TLE Fails on large test cases — Time Limit Exceeded&lt;br&gt;
⚠️  The brute force is logically correct but too slow. For n = 100,000 lines, it would need 10 billion comparisons. We need O(n).&lt;br&gt;
Step 2 — Building the Intuition&lt;br&gt;
This is the most important section. Read it slowly.&lt;/p&gt;

&lt;p&gt;Let’s start with two pointers — one at the leftmost line (index 0) and one at the rightmost line (index n-1). This gives us the maximum possible width.&lt;/p&gt;

&lt;p&gt;Now we calculate the area. Then we ask: should we move the left pointer or the right pointer?&lt;/p&gt;

&lt;p&gt;🤔  Here is the key question: if we move one pointer inward, the WIDTH always decreases. So for the area to possibly increase, the HEIGHT must increase. Which pointer should we move to give the HEIGHT a chance to increase?&lt;br&gt;
The Proof — Why We Always Move the Shorter Line&lt;br&gt;
Say the left line has height 3 and the right line has height 8. The current area is limited by height 3 (the shorter one).&lt;/p&gt;

&lt;p&gt;What if we move the RIGHT pointer (height 8) inward?&lt;br&gt;&lt;br&gt;
Width decreases Always — we moved inward&lt;br&gt;
New right line height   Could be anything — but the area is STILL limited by left line (height 3)&lt;br&gt;
Can area increase?  NO — width went down, height is still capped at 3. Area can only stay same or decrease.&lt;br&gt;
What if we move the LEFT pointer (height 3) inward?&lt;br&gt;&lt;br&gt;
Width decreases Always — we moved inward&lt;br&gt;
New left line height    Could be greater than 3 — this is our only chance for area to increase&lt;br&gt;
Can area increase?  YES — if the new left height is greater than 3, the effective height increases and might outweigh the width decrease&lt;br&gt;
🔑  CONCLUSION: Always move the pointer pointing to the SHORTER line. Moving the taller line’s pointer can never increase the area. Moving the shorter line’s pointer is the only move that gives us a chance at a larger area.&lt;br&gt;
This is the entire algorithm. Everything else — the code, the loop — is just implementing this one insight.&lt;/p&gt;

&lt;p&gt;Step 3 — Full Dry Run&lt;br&gt;
Let’s trace through Example 1 completely.&lt;/p&gt;

&lt;p&gt;Dry Run&lt;/p&gt;

&lt;p&gt;height = [1, 8, 6, 2, 5, 4, 8, 3, 7]&lt;br&gt;
index   = [0, 1, 2, 3, 4, 5, 6, 7, 8]&lt;br&gt;
maxArea = 0&lt;br&gt;
Step    left    right   h[left] h[right]    Width   Height  Area    maxArea Move&lt;br&gt;
1   0   8   1   7   8   1   8   8   left++ (1 &amp;lt; 7)&lt;br&gt;
2   1   8   8   7   7   7   49  49  right– (8 &amp;gt; 7)&lt;br&gt;
3   1   7   8   3   6   3   18  49  right– (8 &amp;gt; 3)&lt;br&gt;
4   1   6   8   8   5   8   40  49  right– (tie → move right)&lt;br&gt;
5   1   5   8   4   4   4   16  49  right– (8 &amp;gt; 4)&lt;br&gt;
6   1   4   8   5   3   5   15  49  right– (8 &amp;gt; 5)&lt;br&gt;
7   1   3   8   2   2   2   4   49  right– (8 &amp;gt; 2)&lt;br&gt;
8   1   2   8   6   1   6   6   49  right– (8 &amp;gt; 6)&lt;br&gt;
9   1   1   – – – – – 49  left &amp;gt;= right → STOP&lt;br&gt;
✅  Maximum area = 49. Found at Step 2: lines at index 1 (height=8) and index 8 (height=7). Width=7, Height=7, Area=49.&lt;br&gt;
Notice something important in Step 4: when both lines have the same height (both are 8), we can move either pointer — it doesn’t matter. Moving either one cannot increase the area since height stays capped at 8 and width decreases.&lt;/p&gt;

&lt;p&gt;READ FULL ARTICLE: &lt;a href="https://dailydevnotes.in/leetcode-11-container-with-most-water/" rel="noopener noreferrer"&gt;https://dailydevnotes.in/leetcode-11-container-with-most-water/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>LeetCode 167 — Two Sum II (Input Array Is Sorted) | Full Solution Explained</title>
      <dc:creator>Irshad's Intersection</dc:creator>
      <pubDate>Fri, 27 Mar 2026 09:40:55 +0000</pubDate>
      <link>https://dev.to/irshads_intersection/leetcode-167-two-sum-ii-input-array-is-sorted-full-solution-explained-5em1</link>
      <guid>https://dev.to/irshads_intersection/leetcode-167-two-sum-ii-input-array-is-sorted-full-solution-explained-5em1</guid>
      <description>&lt;p&gt;Difficulty  Pattern Companies   Leetcode Link&lt;br&gt;
Medium  Two Pointers    Amazon, Google, Microsoft, Adobe    leetcode.com/problems/two-sum-ii-input-array-is-sorted&lt;br&gt;
📌  Before reading this post, I recommend reading the Two Pointers Pattern Guide on this blog. It will make this solution click much faster.&lt;br&gt;
If you’ve solved the original Two Sum (LeetCode #1), you might think this is the same problem. It’s not — and that one small difference (the array is sorted) completely changes the best approach.&lt;/p&gt;

&lt;p&gt;This problem is a textbook example of the Two Pointers pattern. Once you understand why the solution works — not just what the solution is — you’ll be able to apply the same logic to dozens of other problems.&lt;/p&gt;

&lt;p&gt;Let’s go through everything from scratch.&lt;/p&gt;

&lt;p&gt;The Problem&lt;br&gt;
Given a 1-indexed array of integers called numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number.&lt;/p&gt;

&lt;p&gt;Return the indices of the two numbers (1-indexed) as an integer array of length 2.&lt;/p&gt;

&lt;p&gt;Constraint  What it means for us&lt;br&gt;
Array is sorted (non-decreasing)    We can use Two Pointers — smaller values on left, larger on right&lt;br&gt;
Exactly one solution exists We don’t need to handle ‘no answer’ case&lt;br&gt;
1-indexed output    Return index+1 for both answers&lt;br&gt;
Cannot use same element twice   Both pointers must point to different positions&lt;br&gt;
Must use O(1) extra space   No hash map allowed — this forces the Two Pointers approach&lt;br&gt;
Examples&lt;br&gt;
Example 1:&lt;br&gt;
  Input:  numbers = [2, 7, 11, 15],  target = 9&lt;br&gt;
  Output: [1, 2]&lt;br&gt;
  Why:    numbers[0] + numbers[1] = 2 + 7 = 9&lt;/p&gt;

&lt;p&gt;Example 2:&lt;br&gt;
  Input:  numbers = [2, 3, 4],  target = 6&lt;br&gt;
  Output: [1, 3]&lt;br&gt;
  Why:    numbers[0] + numbers[2] = 2 + 4 = 6&lt;/p&gt;

&lt;p&gt;Example 3:&lt;br&gt;
  Input:  numbers = [-1, 0],  target = -1&lt;br&gt;
  Output: [1, 2]&lt;br&gt;
  Why:    numbers[0] + numbers[1] = -1 + 0 = -1&lt;br&gt;
Step 1 — The Brute Force Approach (and Why It’s Not Good Enough)&lt;br&gt;
Before jumping to the optimal solution, let’s think about brute force. This is how most people approach the problem first — and it’s perfectly fine to start here.&lt;/p&gt;

&lt;p&gt;The brute force idea: check every possible pair of numbers. For each element at index i, loop through every element at index j (where j &amp;gt; i) and check if they add up to the target.&lt;/p&gt;

&lt;p&gt;Brute force&lt;br&gt;
// Brute Force — O(n²) time&lt;br&gt;
int n = nums.size();&lt;br&gt;
for (int i = 0; i &amp;lt; n; i++) {&lt;br&gt;
    for (int j = i + 1; j &amp;lt; n; j++) {&lt;br&gt;
        if (nums[i] + nums[j] == target) {&lt;br&gt;
            return {i + 1, j + 1};  // 1-indexed&lt;br&gt;
        }&lt;br&gt;
    }&lt;br&gt;
}&lt;br&gt;
Metric  Brute Force Why it’s a problem&lt;br&gt;
Time Complexity O(n²)  Two nested loops — too slow for large inputs&lt;br&gt;
Space Complexity    O(1)    No extra space — this part is fine&lt;br&gt;
LeetCode Verdict    TLE Will fail on large test cases (Time Limit Exceeded)&lt;br&gt;
⚠️  The brute force works logically but gets TLE on LeetCode for large inputs. The interviewer will ask: ‘Can you do better?’ — and the answer is yes, using Two Pointers.&lt;br&gt;
Step 2 — Build the Intuition (How to Think About It)&lt;br&gt;
Here’s the key question: what does it mean that the array is sorted?&lt;/p&gt;

&lt;p&gt;It means the smallest element is on the left and the largest is on the right. This gives us something very powerful — we can make smart decisions about which direction to move based on whether our current sum is too small or too big.&lt;/p&gt;

&lt;p&gt;🤔  Imagine you start with one pointer at the leftmost element (smallest) and one pointer at the rightmost element (largest). Their sum is either equal to the target, less than the target, or greater than the target.&lt;br&gt;
Current Sum vs Target   What it tells us    What we do&lt;br&gt;
sum == target   Found it!   Return the indices&lt;br&gt;
sum &amp;lt; target    We need a bigger sum    Move LEFT pointer right (increase the smaller number)&lt;br&gt;
sum &amp;gt; target    We need a smaller sum   Move RIGHT pointer left (decrease the larger number)&lt;br&gt;
💡  This works ONLY because the array is sorted. If we need a bigger sum, moving left pointer right always increases the sum. If we need a smaller sum, moving right pointer left always decreases it. This guarantee disappears in an unsorted array.&lt;br&gt;
With this logic, each step either finds the answer or eliminates at least one element from consideration. We never need to backtrack. That’s why this runs in O(n).&lt;/p&gt;

&lt;p&gt;Step 3 — Full Dry Run (Trace Every Step)&lt;br&gt;
Let’s trace through Example 1 in detail.&lt;/p&gt;

&lt;p&gt;Dry Run&lt;/p&gt;

&lt;p&gt;Array:  [2,  7,  11,  15]&lt;br&gt;
Index:   0   1    2    3   (0-based internally, 1-based for output)&lt;br&gt;
Target: 9&lt;br&gt;
Step    left    right   nums[left]  nums[right] Sum Decision&lt;br&gt;
1   0   3   2   15  17  17 &amp;gt; 9  →  move right left&lt;br&gt;
2   0   2   2   11  13  13 &amp;gt; 9  →  move right left&lt;br&gt;
3   0   1   2   7   9   9 == 9  →  FOUND! return [1, 2]&lt;br&gt;
✅  Answer found in just 3 steps on an array of size 4. Brute force would have taken up to 6 comparisons. On large arrays, the difference is enormous.&lt;br&gt;
Now let’s trace Example 2 as well to make sure we fully understand.&lt;/p&gt;

&lt;p&gt;Dry Run&lt;/p&gt;

&lt;p&gt;Array:  [2,  3,  4]&lt;br&gt;
Index:   0   1   2&lt;br&gt;
Target: 6&lt;br&gt;
Step    left    right   numbers[left]   numbers[right]  Sum Decision&lt;br&gt;
1   0   2   2   4   6   6 == 6  →  FOUND! return [1, 3]&lt;br&gt;
And one more — a case where the pointers have to cross the array before finding the answer.&lt;/p&gt;

&lt;p&gt;Dry Run&lt;/p&gt;

&lt;p&gt;Array:  [1,  2,  3,  4,  6]&lt;br&gt;
Index:   0   1   2   3   4&lt;br&gt;
Target: 6&lt;br&gt;
Step    left    right   numbers[left]   numbers[right]  Sum Decision&lt;br&gt;
1   0   4   1   6   7   7 &amp;gt; 6   →  move right left&lt;br&gt;
2   0   3   1   4   5   5 &amp;lt; 6   →  move left right&lt;br&gt;
3   1   3   2   4   6   6 == 6  →  FOUND! return [2, 4]&lt;/p&gt;

&lt;p&gt;READ FULL ARTICLE: &lt;a href="https://dailydevnotes.in/leetcode-167-two-sum-ii-two-pointers/" rel="noopener noreferrer"&gt;https://dailydevnotes.in/leetcode-167-two-sum-ii-two-pointers/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>dsa</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Two Pointers Pattern in DSA — Complete Guide for Beginners</title>
      <dc:creator>Irshad's Intersection</dc:creator>
      <pubDate>Thu, 26 Mar 2026 14:41:25 +0000</pubDate>
      <link>https://dev.to/irshads_intersection/two-pointers-pattern-in-dsa-complete-guide-for-beginners-hgo</link>
      <guid>https://dev.to/irshads_intersection/two-pointers-pattern-in-dsa-complete-guide-for-beginners-hgo</guid>
      <description>&lt;p&gt;This is a pattern guide. After reading this, you will be able to recognise and solve Two Pointers problems confidently — not just memorise one solution.&lt;/p&gt;

&lt;p&gt;Let me ask you something.&lt;/p&gt;

&lt;p&gt;Have you ever solved a LeetCode problem by running two loops — one inside the other — and it worked fine on small inputs but got a ‘Time Limit Exceeded’ on larger ones?&lt;/p&gt;

&lt;p&gt;That’s almost always a sign that the problem has a Two Pointers solution waiting to be discovered.&lt;/p&gt;

&lt;p&gt;Two Pointers is one of the most important patterns in DSA. Once you understand it deeply, you’ll start seeing it everywhere — in array problems, string problems, linked list problems, and even some graph problems.&lt;/p&gt;

&lt;p&gt;This guide explains everything from scratch. No prior pattern knowledge needed.&lt;/p&gt;

&lt;p&gt;What is the Two Pointers Pattern?&lt;br&gt;
The idea is beautifully simple.&lt;/p&gt;

&lt;p&gt;Instead of using one index to loop through an array, you use two — and move them strategically based on some condition. This allows you to check pairs, ranges, or partitions in a single pass instead of nested loops.&lt;/p&gt;

&lt;p&gt;Here’s the key insight:&lt;/p&gt;

&lt;p&gt;💡  A brute force solution that uses two nested loops is O(n²). Two Pointers converts many of those problems to O(n) — a massive improvement.&lt;br&gt;
Think of it like this: imagine you have a sorted array of numbers and you want to find two numbers that add up to a target. The brute force approach checks every pair — that’s n × n combinations. The Two Pointers approach starts one pointer at the left end and one at the right end and works inward — that’s just n steps.&lt;/p&gt;

&lt;p&gt;Same result. Dramatically less work.&lt;/p&gt;

&lt;p&gt;When Should You Use Two Pointers?&lt;br&gt;
The pattern fits when you spot these signals in a problem:&lt;/p&gt;

&lt;p&gt;The input is a sorted array or string (or can be sorted without losing the answer)&lt;br&gt;
You need to find a pair, triplet, or subarray satisfying some condition&lt;br&gt;
You need to compare elements from both ends&lt;br&gt;
You need to remove duplicates or partition elements in-place&lt;br&gt;
The problem asks to minimise or maximise a window between two positions&lt;br&gt;
⚠️  Not every array problem is a Two Pointers problem. If the array is unsorted and sorting changes the answer, think of a different approach.&lt;/p&gt;

&lt;p&gt;Read Full Article: &lt;a href="https://dailydevnotes.in/two-pointers-pattern-dsa/" rel="noopener noreferrer"&gt;https://dailydevnotes.in/two-pointers-pattern-dsa/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>beginners</category>
      <category>dsa</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
