<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Poonam Koundal on Medium]]></title>
        <description><![CDATA[Stories by Poonam Koundal on Medium]]></description>
        <link>https://medium.com/@poonamkoundal.21?source=rss-43f5373ce7a1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*dNNTXxmPVLgVPlp4</url>
            <title>Stories by Poonam Koundal on Medium</title>
            <link>https://medium.com/@poonamkoundal.21?source=rss-43f5373ce7a1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 14:04:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@poonamkoundal.21/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Solving LeetCode #27: The “Filter-in-Place” Strategy Every Junior Dev Needs]]></title>
            <link>https://medium.com/@poonamkoundal.21/solving-leetcode-27-the-filter-in-place-strategy-every-junior-dev-needs-7b0f1a96928a?source=rss-43f5373ce7a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b0f1a96928a</guid>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[leetcode-easy]]></category>
            <category><![CDATA[javascript-interview]]></category>
            <category><![CDATA[remove-elements-in-place]]></category>
            <dc:creator><![CDATA[Poonam Koundal]]></dc:creator>
            <pubDate>Mon, 16 Feb 2026 12:16:49 GMT</pubDate>
            <atom:updated>2026-02-16T12:16:49.078Z</atom:updated>
            <content:encoded><![CDATA[<p>In our last post, we learned how to “clean the junk drawer” by removing duplicates. But what happens when you aren’t just looking for repeats — what if you’re looking for a specific “bad apple” and need it gone?</p><p>Whether you’re clearing out “null” values or filtering a specific ID, <strong>LeetCode #27: Remove Element</strong> is the ultimate test of your efficiency. Most beginners instinctively reach for splice() or try to create a second array, but those methods either slow down your code or hog memory.</p><p>Today, we’re going to reuse our <strong>Leader and Writer</strong> strategy to filter an array “in-place.” By the end of this, you’ll see why the Two-Pointer technique is the most powerful tool in a Junior Developer’s arsenal for writing production-grade, $O(n)$ code.</p><h3># Intuition</h3><p>My first thought when seeing this problem is that we don’t actually need to “delete” items. Deleting in an array is expensive because it forces every other element to shift over.</p><p>Instead, I thought: <strong>“What if I just focus on what I want to keep?”</strong> If I find a number that <em>isn’t</em> the target value, I’ll just shove it to the front of the line.</p><h3># Approach</h3><p>We use the <strong>Two-Pointer technique</strong>, specifically the <strong>Leader and Writer</strong> variation:</p><ol><li><strong>The Writer (</strong><strong>pos):</strong> This pointer stays at the beginning. Its job is to keep track of where the next &quot;valid&quot; (non-target) number should be written.</li><li><strong>The Leader (</strong><strong>i):</strong> This pointer explores the entire array from start to finish.</li><li><strong>The Logic:</strong> As the Leader moves forward, it asks one question: <em>“Is this current number the one we want to get rid of?”</em></li></ol><ul><li><strong>If it IS the target:</strong> The Leader ignores it and moves on.</li><li><strong>If it IS NOT the target:</strong> The Leader tells the Writer, “Hey, this one is good! Write it in your current spot.” Then, the Writer moves up one seat.</li></ul><p>By the end of the loop, the Writer has “packed” all the valid numbers at the front of the array, and the value of pos tells us exactly how many valid numbers we found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qVZadamQ6jKo00rVsUNqsQ.png" /></figure><h3># Complexity</h3><p><strong>Time complexity:</strong></p><p>$O(n)$ : We only walk through the array exactly once with our “Leader” pointer.</p><p><strong>Space complexity:</strong></p><p>$O(1)$: We are modifying the original array in-place and not creating any new arrays or data structures.</p><h3># Code</h3><pre>/**<br> * @param {number[]} nums<br> * @param {number} val<br> * @return {number}<br> */<br>var removeElement = function(nums, val) {<br>    // &#39;pos&#39; is our Writer. It starts at the first index.<br>    let pos = 0;<br><br>    // &#39;i&#39; is our Leader exploring the array.<br>    for (let i = 0; i &lt; nums.length; i++) {<br>        <br>        // If the Leader finds a value that is NOT the target...<br>        if (nums[i] !== val) {<br>            // Write that value into the Writer&#39;s current spot<br>            nums[pos] = nums[i];<br>            <br>            // Move the Writer forward to the next empty spot<br>            pos++;<br>        }<br>    }<br><br>    // After the loop, &#39;pos&#39; equals the number of elements <br>    // that were NOT the target value.<br>    return pos;<br>};</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b0f1a96928a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving LeetCode #26: The “In-Place” Strategy Every Junior Dev Needs]]></title>
            <link>https://medium.com/@poonamkoundal.21/solving-leetcode-26-the-in-place-strategy-every-junior-dev-needs-360cda1e8822?source=rss-43f5373ce7a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/360cda1e8822</guid>
            <category><![CDATA[leetcode-problem]]></category>
            <category><![CDATA[leetcode-easy]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[javascript-array-sort]]></category>
            <category><![CDATA[javascript-interview]]></category>
            <dc:creator><![CDATA[Poonam Koundal]]></dc:creator>
            <pubDate>Fri, 13 Feb 2026 08:29:47 GMT</pubDate>
            <atom:updated>2026-02-13T08:29:47.712Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever tried to organize a messy junk drawer? Usually, you’d take everything out, sort it on the floor, and put it back one by one. In coding, that’s like using “extra memory” to solve a problem.</p><p>But what if you had to organize that drawer <strong>without</strong> taking anything out? What if you had to do it all inside the drawer itself?</p><p>That is the challenge of <strong>“In-Place” array manipulation</strong>. Today, we’re going to look at one of the most famous beginner coding hurdles: <strong>Removing duplicates from a sorted list.</strong> We’ll skip the dry textbook definitions and use a simple “Leader and Writer” strategy that makes this logic feel like a walk in the park.</p><h3>The “Leader and the Writer” Strategy</h3><p>Imagine you have a row of numbered tiles on the floor. Because they are <strong>sorted</strong>, any duplicates are already standing next to each other. To clean them up, you just need two friends: <strong>The Leader</strong> and <strong>The Writer</strong>.</p><h3>1. The Setup</h3><ul><li><strong>The Writer</strong> starts at the very first tile. They are in charge of “locking in” the unique numbers.</li><li><strong>The Leader</strong> starts walking down the line to find the next <em>different</em> number.</li></ul><h3>2. The Rule</h3><p>The Leader walks ahead, tile by tile.</p><ul><li><strong>If the Leader sees the same number</strong> as the Writer, they just keep walking. They don’t care about duplicates!</li><li><strong>If the Leader finds a NEW (larger) number</strong>, they stop.</li></ul><h3>3. The Action</h3><p>When the Leader finds that new number, they “call” the Writer over to the next spot and say: <em>“Hey, write this new number here!”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jnNdHy-K9YdH5R4b5MYeYQ.png" /></figure><h3>The Code Translation</h3><p>Here is how that story looks in JavaScript. Notice how we use writer and leader to keep track of our two friends:</p><pre>var removeDuplicates = function(nums) {<br>    // If the drawer is empty, there&#39;s nothing to do!<br>    if (nums.length === 0) return 0;<br><br>    // The &#39;Writer&#39; starts at the first spot (index 0)<br>    let writer = 0;<br><br>    // The &#39;Leader&#39; explores the rest of the tiles starting from index 1<br>    for (let leader = 1; leader &lt; nums.length; leader++) {<br>        <br>        // If the Leader finds a NEW number that is bigger than the last unique one...<br>        if (nums[leader] &gt; nums[writer]) {<br>            // 1. Move the Writer to the next available spot<br>            writer++; <br>            // 2. Copy the Leader&#39;s number into the Writer&#39;s spot<br>            nums[writer] = nums[leader];<br>        }<br>    }<br><br>    // Since we started counting seats at 0, <br>    // the total count of unique people is writer + 1.<br>    return writer + 1;<br>};</pre><h3>Why this is “Magic”</h3><p>This approach is brilliant because <strong>moving things in an array is expensive.</strong> Usually, if you delete something from the middle of a list, the computer has to slide every other item over to fill the gap.</p><p>With the <strong>Leader and Writer</strong> method, you aren’t “deleting” anything — you are simply <strong>overwriting</strong> the old duplicates with the new unique numbers you find. By the time the Leader reaches the end, all your unique numbers are sitting pretty at the front of the array!</p><h3><strong>Checklist for Success</strong></h3><p>When you’re tackling your next array problem, keep these three golden rules in mind:</p><ol><li><strong>Don’t Forget the First One:</strong> The first item in a sorted list is <em>always</em> unique by default. Start your “Leader” at the second spot to save time.</li><li><strong>Think “Overwrite,” Not “Delete”:</strong> It’s much faster to draw over a duplicate than it is to try and “remove” it and shift the whole array.</li><li><strong>The Index vs. Count Trap:</strong> If your “Writer” ends up at index 4, you actually have <strong>5</strong> unique items. Always check if the problem wants the <em>seat number</em> or the <em>total count</em>.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=360cda1e8822" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>