<?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"><channel><title><![CDATA[Simran Bansal]]></title><description><![CDATA[Simran Bansal]]></description><link>https://blog.sibansal.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Nov 2026 02:00:19 GMT</lastBuildDate><atom:link href="https://blog.sibansal.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Engineering Mental Models]]></title><description><![CDATA[How senior engineers learn, reason, and build better systems]]></description><link>https://blog.sibansal.dev/engineering-mental-models</link><guid isPermaLink="true">https://blog.sibansal.dev/engineering-mental-models</guid><dc:creator><![CDATA[Simran Bansal]]></dc:creator><pubDate>Mon, 14 Sep 2026 16:50:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/650e0ec30011c799f0858b61/4538b242-584e-4463-8faf-4aa7b0df649c.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As software engineers, we spend a lot of time learning.</p>
<p>A new programming language. DSA. System design. Distributed systems. AI. A new codebase. A new domain.</p>
<p>But after years of engineering, I have started to notice something interesting.</p>
<p>The biggest difference between people who learn quickly and people who struggle is often not intelligence.</p>
<p>It is the way they approach what they already know and what they do not know.</p>
<p>There are two very useful ways to approach learning.</p>
<p>One starts with the assumption:</p>
<blockquote>
<p>I probably know this.</p>
</blockquote>
<p>The other starts with:</p>
<blockquote>
<p>I probably do not know this.</p>
</blockquote>
<p>Both are useful.</p>
<p>In fact, I think they map closely to how we do research, debug systems, and build software.</p>
<h2>The same pattern exists in research</h2>
<p>Suppose we want to investigate whether something exists.</p>
<p>We can start with a positive hypothesis:</p>
<blockquote>
<p>I believe X exists. Let me find evidence that validates it.</p>
</blockquote>
<p>Or we can start with a negative hypothesis:</p>
<blockquote>
<p>I believe X does not exist. Let me try to find evidence that proves me wrong.</p>
</blockquote>
<p>The second approach is particularly powerful because it forces us to look for evidence that challenges our assumption.</p>
<p>This is not just a research technique.</p>
<p>It is a learning technique.</p>
<h2>Learning from the top down</h2>
<p>The first approach is:</p>
<blockquote>
<p>I know this already.</p>
</blockquote>
<p>This is the top down approach.</p>
<p>You start with a mental model and try to map the new concept onto it.</p>
<p>For example, when learning a new system design concept, you might already understand caching, databases, queues, load balancers and APIs.</p>
<p>So when someone explains a new architecture, you try to understand it using those existing building blocks.</p>
<p>You are effectively saying:</p>
<blockquote>
<p>I understand the fundamentals. Let me see how this new thing fits into what I already know.</p>
</blockquote>
<p>This approach is fast.</p>
<p>It works especially well when your foundations are strong.</p>
<p>But it has a serious problem.</p>
<p>You can confuse familiarity with understanding.</p>
<p>You read something and think:</p>
<blockquote>
<p>Yes, this makes sense.</p>
</blockquote>
<p>But "makes sense" does not necessarily mean "I can build it."</p>
<p>This is where the second approach becomes useful.</p>
<h2>Learning from the bottom up</h2>
<p>The second approach is:</p>
<blockquote>
<p>I do not know this.</p>
</blockquote>
<p>Instead of trying to confirm your existing mental model, you temporarily assume that your model is incomplete.</p>
<p>You start from the fundamentals.</p>
<p>You observe the concept carefully.</p>
<p>You ask basic questions.</p>
<p><strong>Why</strong> does this exist?</p>
<p>What problem does it solve?</p>
<p>What happens without it?</p>
<p>What assumptions does it make?</p>
<p>Where does it break?</p>
<p>Then you slowly build your understanding from the bottom up.</p>
<p>This approach is slower.</p>
<p>But it is often much deeper.</p>
<p>It exposes gaps that the top down approach can easily hide.</p>
<h2>The real learning framework</h2>
<p>For me, these two approaches come together in a simple four step loop.</p>
<h3>1. State it</h3>
<p>First, state your current understanding.</p>
<p>Do not just read the topic.</p>
<p>Write down what you believe.</p>
<p>For example:</p>
<blockquote>
<p>A cache improves system performance because it reduces database calls.</p>
</blockquote>
<p>That is your current hypothesis.</p>
<p>It may be correct.</p>
<p>It may also be incomplete.</p>
<p>The important thing is that you have made your mental model explicit.</p>
<h3>2. Observe</h3>
<p>Now compare your understanding with reality.</p>
<p>Read the documentation.</p>
<p>Look at an implementation.</p>
<p>Build a small prototype.</p>
<p>Solve a problem.</p>
<p>Debug a real system.</p>
<p>Talk to someone who understands it better.</p>
<p>The goal is not to collect more information.</p>
<p>The goal is to observe where reality agrees or disagrees with your mental model.</p>
<p>For example, you might discover that caching does not simply reduce database calls.</p>
<p>It introduces problems around invalidation, consistency, memory limits, cache stampedes, stale data and failure recovery.</p>
<p>Your original statement was not exactly wrong.</p>
<p>It was incomplete.</p>
<p>That distinction matters.</p>
<h3>3. Refactor</h3>
<p>Now change your mental model.</p>
<p>This is similar to refactoring code.</p>
<p>We do not refactor because the code necessarily fails.</p>
<p>We refactor because our understanding of the problem has improved.</p>
<p>Your original model:</p>
<blockquote>
<p>Cache equals fewer database calls.</p>
</blockquote>
<p>becomes:</p>
<blockquote>
<p>Cache is a separate storage layer that trades freshness and operational complexity for lower latency and reduced load on the underlying data store.</p>
</blockquote>
<p>That is a better mental model.</p>
<p>You have refactored your understanding.</p>
<h3>4. Align fact with actual state</h3>
<p>Finally, check whether your new understanding matches reality.</p>
<p>This is where engineering experience becomes particularly valuable.</p>
<p>It is easy to understand something theoretically.</p>
<p>It is harder to understand how it behaves in an actual system.</p>
<p>Ask:</p>
<blockquote>
<p>If I had to build this today, would I make the same decisions?</p>
</blockquote>
<blockquote>
<p>If this failed in production, would I know why?</p>
</blockquote>
<blockquote>
<p>Can I explain the tradeoffs?</p>
</blockquote>
<blockquote>
<p>Can I recognize when this solution should not be used?</p>
</blockquote>
<p>This is the point where knowledge becomes skill.</p>
<h2>This works for DSA</h2>
<p>Take DSA.</p>
<p>You can learn binary search from the top down.</p>
<p>You might say:</p>
<blockquote>
<p>I know binary search. It works on sorted data and gives O(log n).</p>
</blockquote>
<p>That is useful.</p>
<p>But try the bottom up approach.</p>
<p>Forget the implementation.</p>
<p>Ask:</p>
<blockquote>
<p>What problem is binary search actually solving?</p>
</blockquote>
<p>You are trying to reduce the search space.</p>
<p>Once you understand that, many variations become easier.</p>
<p>Searching for a number is one case.</p>
<p>Finding the first occurrence is another.</p>
<p>Finding a boundary is another.</p>
<p>Searching over an answer space is another.</p>
<p>The implementation changes.</p>
<p>The underlying idea remains.</p>
<p>The goal is not to memorize binary search.</p>
<p>The goal is to understand the invariant.</p>
<p>That is the difference between knowing a solution and knowing a technique.</p>
<h2>This works even better for system design</h2>
<p>System design is where this framework becomes particularly useful.</p>
<p>At an SDE III level, knowing components is not enough.</p>
<p>You probably already know the names:</p>
<p>Load balancer.</p>
<p>Kafka.</p>
<p>Redis.</p>
<p>SQL.</p>
<p>NoSQL.</p>
<p>CDN.</p>
<p>Object storage.</p>
<p>Queues.</p>
<p>Sharding.</p>
<p>Replication.</p>
<p>But knowing the components does not mean you understand system design.</p>
<p>You need to understand why a component exists.</p>
<p>Suppose someone asks:</p>
<blockquote>
<p>Why do we need a queue?</p>
</blockquote>
<p>A top down answer might be:</p>
<blockquote>
<p>Queues provide asynchronous processing.</p>
</blockquote>
<p>Correct.</p>
<p>But a bottom up approach asks:</p>
<blockquote>
<p>What happens if the producer is faster than the consumer?</p>
</blockquote>
<p>Now you are thinking about buffering.</p>
<p>Then:</p>
<blockquote>
<p>What happens if the consumer fails?</p>
</blockquote>
<p>Now you are thinking about durability and retry.</p>
<p>Then:</p>
<blockquote>
<p>What happens if the same message is processed twice?</p>
</blockquote>
<p>Now you are thinking about idempotency.</p>
<p>Then:</p>
<blockquote>
<p>What happens if messages arrive out of order?</p>
</blockquote>
<p>Now you are thinking about ordering guarantees.</p>
<p>The concept becomes much deeper.</p>
<p>You are no longer memorizing "use Kafka."</p>
<p>You are understanding the conditions under which a queue becomes useful.</p>
<p>That is what senior engineering requires.</p>
<h2>AI is no different</h2>
<p>AI can feel especially difficult because there are so many new terms.</p>
<p>Transformers.</p>
<p>Attention.</p>
<p>Embeddings.</p>
<p>Vector databases.</p>
<p>RAG.</p>
<p>Agents.</p>
<p>Fine tuning.</p>
<p>Inference.</p>
<p>Evaluation.</p>
<p>It is tempting to learn these from the top down.</p>
<p>Read an article.</p>
<p>Watch a video.</p>
<p>Understand the terminology.</p>
<p>Move on.</p>
<p>But the bottom up approach can be much more powerful.</p>
<p>Start with:</p>
<blockquote>
<p>What problem are we trying to solve?</p>
</blockquote>
<p>Then:</p>
<blockquote>
<p>What does the model actually receive?</p>
</blockquote>
<blockquote>
<p>What does it produce?</p>
</blockquote>
<blockquote>
<p>Where does the information come from?</p>
</blockquote>
<blockquote>
<p>What happens when the model does not know something?</p>
</blockquote>
<blockquote>
<p>How do we measure whether the answer is good?</p>
</blockquote>
<blockquote>
<p>What changes when we add retrieval?</p>
</blockquote>
<blockquote>
<p>What changes when we add tools?</p>
</blockquote>
<blockquote>
<p>What changes when we add memory?</p>
</blockquote>
<p>Each question forces you to connect the abstraction to an actual mechanism.</p>
<p>Eventually, the buzzwords become less important.</p>
<p>You start seeing the system underneath them.</p>
<h2>The important part is switching between the two</h2>
<p>I do not think top down or bottom up is universally better.</p>
<p>The real skill is knowing when to switch.</p>
<p>If your foundations are strong, start top down.</p>
<p>Try to explain the new concept using what you already know.</p>
<p>Then actively look for contradictions.</p>
<p>Ask:</p>
<blockquote>
<p>Where does my existing model fail?</p>
</blockquote>
<p>That is the negative hypothesis.</p>
<p>Assume your understanding is incomplete and try to break it.</p>
<p>If the topic is completely unfamiliar, start bottom up.</p>
<p>Build the concept from first principles.</p>
<p>Then move upward until you can connect it to larger systems.</p>
<p>So the learning loop becomes:</p>
<p><strong>State → Observe → Refactor → Align</strong></p>
<p>You state what you believe.</p>
<p>You observe reality.</p>
<p>You refactor your mental model.</p>
<p>You align your understanding with the actual system.</p>
<p>Then you repeat.</p>
<h2>This is also how debugging works</h2>
<p>Interestingly, this is almost identical to debugging production systems.</p>
<p>You have an observed symptom.</p>
<p>You form a hypothesis.</p>
<p>You inspect logs, metrics and traces.</p>
<p>You discover that your assumption was incomplete.</p>
<p>You update the hypothesis.</p>
<p>You test again.</p>
<p>Eventually, your mental model matches what the system is actually doing.</p>
<p>Good engineers do this naturally when debugging.</p>
<p>The same habit can be applied deliberately to learning.</p>
<p>Instead of treating learning as consuming information, treat it as debugging your mental model.</p>
<p>That shift is powerful.</p>
<h2>From knowledge to skill</h2>
<p>There is another important distinction.</p>
<p>Knowledge is:</p>
<blockquote>
<p>I understand how this works.</p>
</blockquote>
<p>Skill is:</p>
<blockquote>
<p>I can use it when the situation demands it.</p>
</blockquote>
<p>You can know DSA and still struggle in an interview.</p>
<p>You can know system design concepts and still struggle to design a reliable system.</p>
<p>You can understand AI concepts and still struggle to build a useful AI product.</p>
<p>The missing piece is usually observation and practice.</p>
<p>You need to put your mental model against reality.</p>
<p>Solve the problem.</p>
<p>Build the system.</p>
<p>Read the production code.</p>
<p>Run the experiment.</p>
<p>Break the implementation.</p>
<p>Measure the result.</p>
<p>Then refactor your understanding.</p>
<p>That is how knowledge turns into skill.</p>
<h2>The SDE III perspective</h2>
<p>At junior levels, learning often means collecting concepts.</p>
<p>At more senior levels, learning becomes more about improving mental models.</p>
<p>You stop asking:</p>
<blockquote>
<p>What is Kafka?</p>
</blockquote>
<p>and start asking:</p>
<blockquote>
<p>When does a queue solve the problem better than synchronous communication?</p>
</blockquote>
<p>You stop asking:</p>
<blockquote>
<p>What is Redis?</p>
</blockquote>
<p>and start asking:</p>
<blockquote>
<p>What consistency and failure tradeoffs am I accepting by introducing a cache?</p>
</blockquote>
<p>You stop asking:</p>
<blockquote>
<p>What is sharding?</p>
</blockquote>
<p>and start asking:</p>
<blockquote>
<p>What property of the workload makes partitioning necessary, and what complexity does it introduce?</p>
</blockquote>
<p>You stop asking:</p>
<blockquote>
<p>What is RAG?</p>
</blockquote>
<p>and start asking:</p>
<blockquote>
<p>What knowledge problem are we solving, and how do retrieval quality, context limits and evaluation affect the system?</p>
</blockquote>
<p>That is a different level of learning.</p>
<p>It is less about knowing more things.</p>
<p>It is about having better models of the things you already know.</p>
<h2>A simple rule I try to follow</h2>
<p>When learning something new, I ask myself two questions.</p>
<p>First:</p>
<blockquote>
<p>If I already understood this, how would I explain it?</p>
</blockquote>
<p>That gives me the top down path.</p>
<p>Then:</p>
<blockquote>
<p>What if my understanding is wrong? What evidence would prove me wrong?</p>
</blockquote>
<p>That gives me the bottom up path.</p>
<p>Between these two questions, most of the useful learning happens.</p>
<p>You state your understanding.</p>
<p>You observe reality.</p>
<p>You find the gap.</p>
<p>You refactor your mental model.</p>
<p>Then you check whether the new model actually matches reality.</p>
<p>And that loop works surprisingly well across almost everything we do as engineers.</p>
<p>DSA.</p>
<p>Foundations.</p>
<p>System design.</p>
<p>AI.</p>
<p>Debugging.</p>
<p>Architecture.</p>
<p>Even understanding an unfamiliar codebase.</p>
<p>The subject changes.</p>
<p>The learning mechanism does not.</p>
<p><strong>State. Observe. Refactor. Align.</strong></p>
<p>That is a simple framework, but after enough engineering experience, simple frameworks are often the ones worth keeping.</p>
]]></content:encoded></item><item><title><![CDATA[When a Cron Job Quietly Stopped Processing]]></title><description><![CDATA[A Case Study in Recursive Resource Consumption]]></description><link>https://blog.sibansal.dev/when-a-cron-job-quietly-stopped-processing</link><guid isPermaLink="true">https://blog.sibansal.dev/when-a-cron-job-quietly-stopped-processing</guid><dc:creator><![CDATA[Simran Bansal]]></dc:creator><pubDate>Mon, 07 Sep 2026 09:54:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/650e0ec30011c799f0858b61/7a772ac8-9f87-4b36-bff0-5ffa1dbe2643.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Overview</h2>
<p>A backend job was responsible for processing a large number of pending tasks. On paper, the implementation looked straightforward. The cron job picked up pending cases, processed them, and moved on.</p>
<p>But in production, something strange was happening.</p>
<p>The job was expected to process around <strong>1,020 tasks</strong>, but consistently stopped after processing roughly <strong>120 tasks</strong>.</p>
<p>There were no obvious application errors. The service was not throwing exceptions. The logs did not point to a failed business operation.</p>
<p>Instead, the pods were restarting.</p>
<p>At first glance, this looked like an infrastructure problem.</p>
<p>It wasn't.</p>
<p>The real problem was buried several layers deeper in the application code: a recursive method used to process the remaining cases was consuming significantly more resources than expected.</p>
<p>The fix was not to increase pod resources or change the cron configuration. The underlying processing logic had to be changed.</p>
<hr />
<h2>Problem Statement</h2>
<p>We had multiple cron jobs responsible for processing different types of pending cases.</p>
<p>Each job followed roughly the same pattern:</p>
<ol>
<li><p>Find pending cases.</p>
</li>
<li><p>Process them.</p>
</li>
<li><p>Continue until all eligible cases were handled.</p>
</li>
</ol>
<p>One particular job had approximately <strong>1,020 tasks</strong> to process.</p>
<p>However, during execution, it would process only about <strong>120 tasks</strong> before the pod restarted.</p>
<p>What made the issue particularly difficult was the absence of a clear application error.</p>
<p>There was no useful exception pointing directly to the problem.</p>
<p>The code also looked reasonable during the initial review.</p>
<p>This is one of those production issues where everything appears to be working correctly until you look at what the system is actually doing at runtime.</p>
<hr />
<h2>The Initial Investigation</h2>
<p>The first assumption was that the cron job itself might be responsible.</p>
<p>There were multiple cron jobs running different processing flows, so the investigation started around scheduling and job execution.</p>
<p>The questions were fairly basic:</p>
<ul>
<li><p>Was the cron triggering multiple times?</p>
</li>
<li><p>Were jobs overlapping?</p>
</li>
<li><p>Was one job consuming resources needed by another?</p>
</li>
<li><p>Was Kubernetes restarting the pod because of memory pressure?</p>
</li>
<li><p>Was there an unhandled exception?</p>
</li>
<li><p>Was the database query returning unexpected results?</p>
</li>
</ul>
<p>Nothing immediately explained why processing consistently stopped around the same point.</p>
<p>The application logic appeared correct.</p>
<p>That was the interesting part.</p>
<p>When a piece of code looks correct but the process keeps disappearing, it is often worth looking beyond the business logic and asking a different question:</p>
<p><strong>What is this code making the runtime do?</strong></p>
<hr />
<h2>Finding the Real Problem</h2>
<p>While tracing the processing flow, I found that the method responsible for handling pending cases was calling itself recursively.</p>
<p>The recursive call was being used to continue processing the remaining cases.</p>
<p>Conceptually, the code looked something like this:</p>
<pre><code class="language-javascript">function processCases(cases) {
    // process current cases

    if (remainingCases.length &gt; 0) {
        processCases(remainingCases);
    }
}
</code></pre>
<p>There was nothing obviously wrong with this approach.</p>
<p>The termination condition existed.</p>
<p>The pending cases were eventually reduced.</p>
<p>The business logic was correct.</p>
<p>But the problem was not correctness.</p>
<p>It was <strong>resource consumption</strong>.</p>
<p>Once I looked at the method from a complexity perspective rather than just reading it as business logic, the problem became much clearer.</p>
<hr />
<h2>The Complexity Was the Clue</h2>
<p>The recursive implementation was doing more work than the code initially suggested.</p>
<p>During a dry analysis of the method, the execution pattern could be represented approximately as:</p>
<p><strong>2T(n/2) + n</strong></p>
<p>That recurrence resolves to:</p>
<p><strong>O(n log n)</strong></p>
<p>For a small number of records, that difference might not matter.</p>
<p>But this wasn't a small dataset running in isolation.</p>
<p>The method was running inside a backend service, alongside other scheduled jobs, database operations, request handling, and other application workloads.</p>
<p>The important lesson here is that <strong>algorithmic complexity does not exist in isolation from the runtime environment</strong>.</p>
<p>A method that looks harmless when processing a few dozen records can become expensive when:</p>
<ul>
<li><p>the input grows,</p>
</li>
<li><p>multiple jobs execute concurrently,</p>
</li>
<li><p>the same pod handles other workloads,</p>
</li>
<li><p>recursion increases stack usage,</p>
</li>
<li><p>intermediate objects remain alive longer than expected.</p>
</li>
</ul>
<p>That combination was enough to turn a seemingly correct implementation into a production resource problem.</p>
<hr />
<h2>Why the Pod Restart Was Misleading</h2>
<p>The most misleading part of the incident was the pod restart.</p>
<p>From an operational perspective, the symptom looked like:</p>
<pre><code class="language-text">Cron job starts
        ↓
Processes some records
        ↓
Pod restarts
        ↓
Remaining records stay pending
</code></pre>
<p>It was tempting to treat the restart as the problem.</p>
<p>But the restart was actually the <strong>symptom</strong>.</p>
<p>The application was putting enough pressure on the available resources that the process could not continue normally.</p>
<p>This distinction matters a lot when debugging distributed systems.</p>
<p>A restart does not necessarily tell you what caused the failure.</p>
<p>It tells you that something upstream eventually made the process unable to continue.</p>
<p>In this case, the cron job was only the trigger. The deeper issue was how the processing algorithm consumed resources.</p>
<hr />
<h2>The Fix</h2>
<p>The recursive processing was rewritten as an iterative flow.</p>
<p>Instead of repeatedly calling the same method and creating another stack frame, the processing was handled through an explicit loop.</p>
<p>Conceptually:</p>
<pre><code class="language-javascript">function processCases(cases) {
    while (cases.length &gt; 0) {
        // process cases

        cases = getRemainingCases();
    }
}
</code></pre>
<p>The exact implementation was more specific to the application, but the important change was architectural:</p>
<p><strong>recursion was replaced with iteration.</strong></p>
<p>This removed the repeated recursive call chain and reduced the algorithmic overhead.</p>
<p>The resulting approach was reduced to:</p>
<p><strong>O(n)</strong></p>
<p>More importantly, the processing became much more predictable from a resource consumption perspective.</p>
<hr />
<h2>The Other Problem: Multiple Cron Jobs</h2>
<p>While fixing the recursive processing issue, another problem became apparent.</p>
<p>The application had multiple cron jobs processing different categories of cases.</p>
<p>Each job was reasonable when considered independently.</p>
<p>The problem was that they did not run independently from the perspective of the pod.</p>
<p>They competed for the same resources.</p>
<p>A useful way to think about it is:</p>
<pre><code class="language-text">                Kubernetes Pod
                      |
        +-------------+-------------+
        |             |             |
     Cron A        Cron B        Cron C
        |             |             |
     Database      Database      Database
     CPU/Memory    CPU/Memory    CPU/Memory
</code></pre>
<p>Even if each cron job was within an acceptable resource range individually, running several of them at the same time could create a very different system profile.</p>
<p>The recursive processing amplified that problem.</p>
<p>So the fix wasn't limited to the algorithm.</p>
<p>The cron execution strategy also needed to be reviewed.</p>
<hr />
<h2>What Changed</h2>
<p>The final solution had two parts.</p>
<h3>1. Replace Recursive Processing</h3>
<p>The recursive processing flow was converted into an iterative implementation.</p>
<p>This reduced the computational overhead and made resource consumption more predictable.</p>
<h3>2. Review Cron Execution</h3>
<p>The multiple cron jobs were adjusted so they would not unnecessarily compete with each other for the same resources.</p>
<p>The goal was not simply to make the cron jobs slower or add arbitrary delays.</p>
<p>The goal was to make the overall workload predictable.</p>
<p>This is an important distinction.</p>
<p>When a backend system has several scheduled workloads, <strong>concurrency should be an intentional design decision, not an accidental side effect of cron schedules.</strong></p>
<hr />
<h2>Why the Obvious Fix Would Have Been Wrong</h2>
<p>There were several tempting solutions that would have treated the symptom rather than the cause.</p>
<h3>Increase Pod Memory</h3>
<p>This might have allowed the job to process more records.</p>
<p>But it would not have fixed the inefficient processing algorithm.</p>
<p>Eventually, the dataset could grow again and expose the same problem.</p>
<h3>Increase the Number of Pods</h3>
<p>This would not necessarily help either.</p>
<p>If the cron workload was not designed for parallel execution, more pods could actually make the situation worse by allowing the same scheduled work to execute concurrently.</p>
<h3>Increase the Cron Interval</h3>
<p>This could reduce contention between jobs, but it would still leave the expensive recursive processing untouched.</p>
<p>These are useful operational levers, but they should not be the first response to an algorithmic problem.</p>
<hr />
<h2>What I Learned</h2>
<p>The biggest lesson from this incident was that <strong>correct code can still be operationally wrong</strong>.</p>
<p>The recursive method had a valid termination condition.</p>
<p>The business logic was correct.</p>
<p>There was no obvious exception.</p>
<p>Yet the implementation was still capable of consuming enough resources to affect the stability of the service.</p>
<p>That changed the way I look at production debugging.</p>
<p>When a job mysteriously stops, I don't only ask:</p>
<blockquote>
<p>"Where did the code fail?"</p>
</blockquote>
<p>I also ask:</p>
<blockquote>
<p>"What is the code making the system do?"</p>
</blockquote>
<p>Those are very different questions.</p>
<p>The second one often leads you toward CPU consumption, memory allocation, recursion depth, database load, concurrency, connection pools, queue pressure, and other runtime characteristics that aren't obvious from the business logic alone.</p>
<hr />
<h2>Key Takeaways</h2>
<ul>
<li><p>A pod restart is a symptom, not necessarily the root cause.</p>
</li>
<li><p>Code can be logically correct and still have unacceptable runtime characteristics.</p>
</li>
<li><p>Recursive processing deserves careful review when handling large datasets.</p>
</li>
<li><p>Algorithmic complexity matters even more when workloads run concurrently.</p>
</li>
<li><p>Multiple cron jobs sharing the same pod can amplify resource contention.</p>
</li>
<li><p>Increasing infrastructure resources is not a substitute for fixing inefficient application logic.</p>
</li>
<li><p>Production debugging often requires looking at the interaction between <strong>algorithm, workload, and infrastructure</strong>, rather than examining each one independently.</p>
</li>
</ul>
<hr />
<h2>Conclusion</h2>
<p>What initially looked like a cron or Kubernetes problem turned out to be an application design problem.</p>
<p>A job expected to process around 1,020 tasks was consistently stopping after roughly 120. There were no obvious application errors, and the code looked correct during an initial review.</p>
<p>The breakthrough came from stepping back from the business logic and analyzing the execution characteristics of the processing method.</p>
<p>The recursive implementation was doing more work than necessary, and its resource consumption became particularly problematic when multiple cron jobs were running in the same environment.</p>
<p>Replacing the recursive flow with an iterative one brought the processing down to <strong>O(n)</strong> and made its resource usage more predictable. Reviewing the cron execution model addressed the second part of the problem: competing scheduled workloads.</p>
<p>The incident was a good reminder that backend engineering is rarely about fixing the line where something breaks.</p>
<p><strong>Sometimes the real bug is hiding in code that is completely correct.</strong></p>
]]></content:encoded></item><item><title><![CDATA[The Only 25 Patterns You Need to Master DSA]]></title><description><![CDATA[Stop Memorizing Problems. Start Recognizing Patterns.]]></description><link>https://blog.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa</link><guid isPermaLink="true">https://blog.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa</guid><dc:creator><![CDATA[Simran Bansal]]></dc:creator><pubDate>Tue, 11 Aug 2026 11:46:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/650e0ec30011c799f0858b61/af124f86-9b2b-45bd-89f2-0cda4238f0f2.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>There are thousands of coding problems, but there are far fewer <strong>ways of thinking</strong> about those problems.</p>
<p>That is the central idea behind pattern-based DSA preparation.</p>
<p>You do not need to memorize 500 solutions. You need to recognize that a new problem is often a variation of something you have already solved.</p>
<p>A string problem may secretly be a Sliding Window problem. A linked-list problem may secretly be a Fast &amp; Slow Pointer problem. A scheduling problem may secretly be a Merge Intervals problem. A dependency problem may secretly be a Topological Sort problem. A shortest-path problem may secretly be a Dijkstra problem. And a seemingly impossible optimization problem may simply be Dynamic Programming.</p>
<p>This article organizes DSA into <strong>25 reusable patterns</strong>. For each pattern, you get: why it exists, when to recognize it, pseudocode you can implement from, a worked example, a real-world application, and four hand-picked LeetCode problems (1 Easy, 2 Medium, 1 Hard — with a note wherever LeetCode itself doesn't offer a clean problem at that difficulty).</p>
<blockquote>
<p><strong>On the links below:</strong> every LeetCode link in this article was checked against LeetCode's own listed difficulty before being included, and <strong>every problem in this version is free</strong> — nothing requires a LeetCode subscription. A few patterns (Dijkstra, Topological Sort) don't have a clean, freely-accessible Easy problem on LeetCode; rather than mislabel a Medium as Easy, those sections say so explicitly instead.</p>
</blockquote>
<hr />
<h2>How to use this article</h2>
<p>Ask what the data looks like, then match it to a family of patterns:</p>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-1.png" alt="DSA pattern visualization 1" style="display:block;margin:0 auto" />

<h2>🎮 Interactive Playground</h2>
<p>Practice all 25 patterns interactively with 99 problems:</p>
<p>👉 <a href="https://playground.sibansal.dev/dsa_25_patterns_all_article_problems_interactive.html">Open DSA 25 Patterns Interactive Playground</a></p>
<hr />
<h1>The 25 Patterns</h1>
<pre><code class="language-plaintext">1.  Two Pointers
2.  Fast &amp; Slow Pointers
3.  Sliding Window
4.  Prefix Sum
5.  HashMap
6.  Stack
7.  Queue
8.  Sorting
9.  Binary Search
10.  Merge Intervals
11.  Bitwise Operations
12.  Heap / Priority Queue
13.  Top K Elements
14.  K-Way Merge
15.  Trees &amp; Tree Traversals
16.  Depth First Search — DFS
17.  Breadth First Search — BFS
18.  Graphs
19.  Greedy
20.  Trie
21.  Topological Sort
22.  Dijkstra's Algorithm
23.  Dynamic Programming — 1D
24.  Dynamic Programming — 2D / Grid
25.  Backtracking
</code></pre>
<hr />
<h1>1. Two Pointers</h1>
<h2>Motivation</h2>
<p>Two Pointers is one of the most important techniques for arrays, strings, and linked structures. Instead of repeatedly examining every pair of elements, we maintain two positions and move them according to a rule. The pattern is particularly powerful when the data is sorted, when we need to compare elements from opposite ends, or when we need to maintain a relationship between two positions. Many O(n²) brute-force solutions become O(n) with the correct pointer movement.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-2.png" alt="DSA pattern visualization 2" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">left = 0
right = n - 1

while left &lt; right:
    evaluate(left, right)

    if condition says move left:
        left++
    else:
        right--
</code></pre>
<h2>Example</h2>
<p>Find whether a sorted array contains two numbers whose sum equals <code>target</code>.</p>
<pre><code class="language-plaintext">left = 0
right = n - 1

while left &lt; right:
    sum = nums[left] + nums[right]
    if sum == target:
        return true
    if sum &lt; target:
        left++
    else:
        right--

return false
</code></pre>
<p>For <code>nums = [1, 2, 4, 7, 11]</code>, <code>target = 9</code>:</p>
<p>Start with <code>1 + 11 = 12</code> → too large → move <code>right</code>. Then <code>1 + 7 = 8</code> → too small → move <code>left</code>. Then <code>2 + 7 = 9</code> → found.</p>
<h2>Real-world application</h2>
<p>Two pointers appear in comparing sorted datasets, merging streams, finding matching ranges, memory-efficient array processing, removing duplicates in-place, and partitioning data.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/valid-palindrome/">Valid Palindrome</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/3sum/">3Sum</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/container-with-most-water/">Container With Most Water</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/trapping-rain-water/">Trapping Rain Water</a></td>
</tr>
</tbody></table>
<hr />
<h1>2. Fast &amp; Slow Pointers</h1>
<h2>Motivation</h2>
<p>Fast and Slow Pointers are designed for situations where you need to detect cycles, find the middle of a linked list, or reason about repeated states without storing every visited position. One pointer moves faster than the other. If a cycle exists, the faster pointer eventually catches the slower pointer. This eliminates extra memory and often turns a problem requiring a visited set into an O(1)-space solution.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-3.png" alt="DSA pattern visualization 3" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">slow = head
fast = head

while fast != null and fast.next != null:
    slow = slow.next
    fast = fast.next.next

    if slow == fast:
        return true

return false
</code></pre>
<h2>Example</h2>
<p>For <code>1 → 2 → 3 → 4 → 5</code>: slow moves one node at a time, fast moves two. When fast reaches the end, slow sits at <code>3</code> — the middle of the list.</p>
<h2>Real-world application</h2>
<p>Cycle detection, linked-list processing, detecting repeated states, circular buffers, and algorithms involving periodic sequences.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/middle-of-the-linked-list/">Middle of the Linked List</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/remove-nth-node-from-end-of-list/">Remove Nth Node From End of List</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/find-the-duplicate-number/">Find the Duplicate Number</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/longest-duplicate-substring/">Longest Duplicate Substring</a></td>
</tr>
</tbody></table>
<blockquote>
<p><strong>Note:</strong> Fast/Slow Pointer is predominantly an Easy/Medium pattern on LeetCode. The Hard problem above leans on a different, string-hashing style of repeated-state reasoning rather than the classic two-pointer cycle walk — don't expect every Hard linked-list problem to use the exact same pointer movement.</p>
</blockquote>
<hr />
<h1>3. Sliding Window</h1>
<h2>Motivation</h2>
<p>Sliding Window is the natural pattern whenever a problem asks about a <strong>contiguous</strong> portion of an array or string. Instead of recalculating every possible subarray, maintain a window <code>[left, right]</code> and update it incrementally. When the current window violates a constraint, move <code>left</code>. When it remains valid, expand <code>right</code>. This often converts O(n²) substring or subarray enumeration into O(n).</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-4.png" alt="DSA pattern visualization 4" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">left = 0

for right in range(n):
    add nums[right] to window

    while window is invalid:
        remove nums[left]
        left++

    update answer
</code></pre>
<h2>Example</h2>
<p>Longest substring without repeating characters, <code>s = "abcabcbb"</code>:</p>
<p>Expand: <code>a</code>, <code>ab</code>, <code>abc</code>. The next <code>a</code> creates a duplicate, so shrink from the left until the window is valid again. The maximum length is <code>3</code>.</p>
<h2>Real-world application</h2>
<p>Network traffic monitoring, rate limiting, log analysis, time-series analytics, streaming data, and substring searches.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/maximum-average-subarray-i/">Maximum Average Subarray I</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/longest-substring-without-repeating-characters/">Longest Substring Without Repeating Characters</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/permutation-in-string/">Permutation in String</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/minimum-window-substring/">Minimum Window Substring</a></td>
</tr>
</tbody></table>
<hr />
<h1>4. Prefix Sum</h1>
<h2>Motivation</h2>
<p>Prefix Sum avoids repeated summation. If a problem repeatedly asks for the sum of a range, calculate cumulative information once and answer each range query in O(1). The deeper lesson: many problems become easier when you transform raw data into cumulative state. Prefix sums also combine extremely well with HashMaps, turning many subarray problems from quadratic into linear time.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-5.png" alt="DSA pattern visualization 5" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">prefix[0] = 0

for i in range(n):
    prefix[i + 1] = prefix[i] + nums[i]

rangeSum(l, r) = prefix[r + 1] - prefix[l]
</code></pre>
<h2>Example</h2>
<p><code>nums = [2, 4, 3, 5]</code> → prefix = <code>[0, 2, 6, 9, 14]</code>.</p>
<p>Sum from index <code>1</code> to <code>3</code> = <code>prefix[4] - prefix[1] = 14 - 2 = 12</code>.</p>
<h2>Real-world application</h2>
<p>Financial cumulative totals, image processing, range analytics, database aggregation, frequency counting, and time-series calculations.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/running-sum-of-1d-array/">Running Sum of 1d Array</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/subarray-sum-equals-k/">Subarray Sum Equals K</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/product-of-array-except-self/">Product of Array Except Self</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays/">Maximum Sum of 3 Non-Overlapping Subarrays</a></td>
</tr>
</tbody></table>
<hr />
<h1>5. HashMap</h1>
<h2>Motivation</h2>
<p>HashMaps are the answer whenever a problem asks you to remember something and retrieve it quickly. Instead of repeatedly scanning an array, store information in a hash table and achieve average O(1) lookup. HashMaps are powerful for frequency counting, complement searching, grouping, duplicate detection, and tracking previously seen states.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-6.png" alt="DSA pattern visualization 6" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">map = {}

for item in data:
    if item exists in map:
        use stored information
    map[item] = updated information
</code></pre>
<h2>Example</h2>
<p>Two Sum, <code>nums = [2,7,11,15]</code>, <code>target = 9</code>. At <code>2</code>, we need <code>7</code> → store <code>2 → index 0</code>. At <code>7</code>, we need <code>2</code> → it already exists → answer <code>[0,1]</code>.</p>
<h2>Real-world application</h2>
<p>Caching, database indexing, frequency analysis, deduplication, lookup services, and session management.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/two-sum/">Two Sum</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/group-anagrams/">Group Anagrams</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/longest-consecutive-sequence/">Longest Consecutive Sequence</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/substring-with-concatenation-of-all-words/">Substring with Concatenation of All Words</a></td>
</tr>
</tbody></table>
<hr />
<h1>6. Stack</h1>
<h2>Motivation</h2>
<p>A Stack represents <strong>Last In, First Out</strong> behavior. It appears whenever the most recently opened, created, or processed item must be handled first — parentheses matching, expression evaluation, undo operations, browser history, and monotonic-stack problems all depend on stack-like reasoning. The important extension is the <strong>Monotonic Stack</strong>, which maintains increasing or decreasing values to efficiently answer "next greater/smaller" questions.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-7.png" alt="DSA pattern visualization 7" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">stack = []

for item in data:
    while stack is not empty and condition(stack.top, item):
        process(stack.pop())

    stack.push(item)
</code></pre>
<h2>Example</h2>
<p>Valid parentheses <code>([{}])</code>: every closing bracket must match the most recently opened bracket, which is exactly what a stack tracks.</p>
<h2>Real-world application</h2>
<p>Undo/redo, browser navigation, compiler parsing, expression evaluation, call stacks, and next-event processing.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/valid-parentheses/">Valid Parentheses</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/min-stack/">Min Stack</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/daily-temperatures/">Daily Temperatures</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/largest-rectangle-in-histogram/">Largest Rectangle in Histogram</a></td>
</tr>
</tbody></table>
<hr />
<h1>7. Queue</h1>
<h2>Motivation</h2>
<p>A Queue represents <strong>First In, First Out</strong> behavior — the natural structure for processing things in arrival order. Queues become especially important combined with BFS, where each layer of a graph or tree is processed before moving deeper. Deques (double-ended queues) allow insertion and removal from both ends and enable techniques such as Sliding Window Maximum.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-8.png" alt="DSA pattern visualization 8" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">queue.push(start)

while queue is not empty:
    current = queue.popFront()
    process(current)

    for next in current.neighbors:
        queue.push(next)
</code></pre>
<h2>Example</h2>
<p>People entering a service queue <code>A → B → C</code>: A is processed first, then B, then C.</p>
<h2>Real-world application</h2>
<p>Job scheduling, print queues, request processing, BFS, message brokers, and customer service systems.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/number-of-recent-calls/">Number of Recent Calls</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/design-circular-queue/">Design Circular Queue</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/rotting-oranges/">Rotting Oranges</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/sliding-window-maximum/">Sliding Window Maximum</a></td>
</tr>
</tbody></table>
<hr />
<h1>8. Sorting</h1>
<h2>Motivation</h2>
<p>Sorting transforms an unstructured problem into an ordered one. Once elements are sorted, duplicate detection, interval processing, two-pointer techniques, greedy decisions, and binary search often become possible. Understand not just how library sorting works, but the fundamental ideas behind Merge Sort, Quick Sort, Heap Sort, Counting Sort, and partitioning.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-9.png" alt="DSA pattern visualization 9" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">mergeSort(array):
    if size &lt;= 1:
        return array

    left = mergeSort(left half)
    right = mergeSort(right half)

    return merge(left, right)
</code></pre>
<h2>Example</h2>
<p><code>[5, 2, 8, 1]</code> → split into <code>[5,2] [8,1]</code> → sort into <code>[2,5] [1,8]</code> → merge into <code>[1,2,5,8]</code>.</p>
<h2>Real-world application</h2>
<p>Database <code>ORDER BY</code>, ranking systems, report generation, scheduling, deduplication, and search preprocessing.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/merge-sorted-array/">Merge Sorted Array</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/sort-colors/">Sort Colors</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/sort-an-array/">Sort an Array</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/reverse-pairs/">Reverse Pairs</a></td>
</tr>
</tbody></table>
<hr />
<h1>9. Binary Search</h1>
<h2>Motivation</h2>
<p>Binary Search is not simply "searching a sorted array." Its real power is <strong>eliminating half the search space whenever a condition is monotonic</strong>. This means Binary Search applies to arrays, answer spaces, capacities, speeds, times, and many optimization problems. The key question: "Can I determine which half cannot contain the answer?"</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-10.png" alt="DSA pattern visualization 10" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">left = low
right = high

while left &lt;= right:
    mid = left + (right - left) / 2

    if found:
        return mid

    if target belongs to left half:
        right = mid - 1
    else:
        left = mid + 1

return -1
</code></pre>
<h2>Example</h2>
<p><code>nums = [1,3,5,7,9]</code>, <code>target = 7</code>. Check <code>5</code> → too small, discard left half. Check <code>7</code> → found.</p>
<h2>Real-world application</h2>
<p>Database indexes, filesystem searches, capacity planning, finding minimum feasible resources, and optimization problems.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/binary-search/">Binary Search</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/search-in-rotated-sorted-array/">Search in Rotated Sorted Array</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/koko-eating-bananas/">Koko Eating Bananas</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/median-of-two-sorted-arrays/">Median of Two Sorted Arrays</a></td>
</tr>
</tbody></table>
<hr />
<h1>10. Merge Intervals</h1>
<h2>Motivation</h2>
<p>Whenever data represents ranges — meetings, bookings, reservations, time periods, memory regions — think in intervals. The key idea is usually to sort intervals by their starting point and then process them left to right. Once sorted, overlapping intervals become easy to identify because the next interval can only interact with the current merged interval.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-11.png" alt="DSA pattern visualization 11" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">sort intervals by start
result = []

for interval in intervals:
    if result is empty or interval.start &gt; result.last.end:
        result.append(interval)
    else:
        result.last.end = max(result.last.end, interval.end)

return result
</code></pre>
<h2>Example</h2>
<p><code>[1,3] [2,6] [8,10] [15,18]</code> → first two overlap into <code>[1,6]</code>.</p>
<p>Final result: <code>[1,6], [8,10], [15,18]</code>.</p>
<h2>Real-world application</h2>
<p>Calendar scheduling, reservation systems, CPU scheduling, network maintenance windows, and resource allocation.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/summary-ranges/">Summary Ranges</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/merge-intervals/">Merge Intervals</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/insert-interval/">Insert Interval</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/the-skyline-problem/">The Skyline Problem</a></td>
</tr>
</tbody></table>
<blockquote>
<p><strong>Note:</strong> LeetCode's cleanest Easy interval-merge problems (Meeting Rooms, Meeting Rooms II) are Premium-only. Summary Ranges is the free Easy substitute — it's a step removed from overlapping-interval merging (it groups consecutive <em>integers</em> into ranges rather than merging overlapping <em>intervals</em>), but it exercises the same left-pointer/right-pointer range-building instinct. The Skyline Problem is a free Hard problem that leans on the interval sweep-line idea, coordinating many overlapping ranges at once.</p>
</blockquote>
<hr />
<h1>11. Bitwise Operations</h1>
<h2>Motivation</h2>
<p>Bitwise operations manipulate the individual binary bits of integers. A small set of operations — AND, OR, XOR, NOT, left shift, right shift — solves a surprising number of problems. XOR is particularly important because <code>x ^ x = 0</code> and <code>x ^ 0 = x</code>. Bit manipulation can produce extremely efficient solutions for parity, masks, subsets, state representation, and duplicate cancellation.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-12.png" alt="DSA pattern visualization 12" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext"># Check bit
(n &amp; (1 &lt;&lt; k)) != 0

# Set bit
n = n | (1 &lt;&lt; k)

# Clear bit
n = n &amp; ~(1 &lt;&lt; k)

# XOR matching pairs
answer = 0
for x in nums:
    answer = answer ^ x
</code></pre>
<h2>Example</h2>
<p>Find the single number in <code>[4,1,2,1,2]</code>: XOR everything. Since <code>1^1=0</code> and <code>2^2=0</code>, the result is <code>4</code>.</p>
<h2>Real-world application</h2>
<p>Permissions, feature flags, network masks, compression, cryptography primitives, and compact state representation.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/single-number/">Single Number</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/counting-bits/">Counting Bits</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/">Maximum XOR of Two Numbers in an Array</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero/">Triples with Bitwise AND Equal To Zero</a></td>
</tr>
</tbody></table>
<hr />
<h1>12. Heap / Priority Queue</h1>
<h2>Motivation</h2>
<p>A Heap is useful when you repeatedly need the smallest or largest element while the rest of the data stays unsorted. A sorted array requires expensive updates; a heap provides efficient insertion and removal of the current min/max. Priority Queues are essential for scheduling, Top K problems, Dijkstra, streaming medians, and resource allocation. Key question: "Do I repeatedly need the best current candidate?"</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-13.png" alt="DSA pattern visualization 13" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">heap = empty

for value in data:
    push(heap, value)

while heap is needed:
    best = popMin(heap)
    process(best)
</code></pre>
<h2>Example</h2>
<p>Tasks <code>A→priority 3, B→priority 1, C→priority 2</code>. A priority queue returns them in order: <code>B, C, A</code>.</p>
<h2>Real-world application</h2>
<p>CPU scheduling, network packet prioritization, hospital triage, event simulation, task queues, and shortest-path algorithms.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/last-stone-weight/">Last Stone Weight</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/kth-largest-element-in-an-array/">Kth Largest Element in an Array</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/top-k-frequent-elements/">Top K Frequent Elements</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/find-median-from-data-stream/">Find Median from Data Stream</a></td>
</tr>
</tbody></table>
<hr />
<h1>13. Top K Elements</h1>
<h2>Motivation</h2>
<p>Top K problems ask for only a small number of extreme elements rather than a fully sorted dataset. Sorting everything costs O(n log n), but if <code>k</code> is small, a heap can maintain only the best K candidates. The question is not "how do I sort the array?" but "how do I keep only the K elements that matter?"</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-14.png" alt="DSA pattern visualization 14" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">minHeap = empty

for value in data:
    push(minHeap, value)

    if heap.size &gt; k:
        popMin(minHeap)

return minHeap
</code></pre>
<h2>Example</h2>
<p><code>nums = [3,2,1,5,6,4]</code>, <code>k = 2</code> → maintain only two largest values → result <code>5, 6</code>.</p>
<h2>Real-world application</h2>
<p>Top search results, most popular products, highest salaries, most frequent events, recommendation systems, and ranking.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/kth-largest-element-in-a-stream/">Kth Largest Element in a Stream</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/kth-largest-element-in-an-array/">Kth Largest Element in an Array</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/top-k-frequent-elements/">Top K Frequent Elements</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/sliding-window-median/">Sliding Window Median</a></td>
</tr>
</tbody></table>
<hr />
<h1>14. K-Way Merge</h1>
<h2>Motivation</h2>
<p>K-Way Merge extends the classic two-array merge to many already-sorted sequences. The challenge is repeatedly identifying the smallest current element across K sources. A Min Heap makes this efficient: keep one candidate from each source, remove the smallest, then insert the next element from that same source.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-15.png" alt="DSA pattern visualization 15" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">heap = first element from each sorted list

while heap is not empty:
    value, source = popMin(heap)
    output value

    if source has next element:
        push(heap, next value from source)
</code></pre>
<h2>Example</h2>
<p><code>A=[1,4,7] B=[2,5,8] C=[3,6,9]</code>. Heap starts with <code>1,2,3</code>. Remove <code>1</code>, insert <code>4</code> → heap becomes <code>2,3,4</code>. Continue until all elements are merged.</p>
<h2>Real-world application</h2>
<p>Merging database partitions, external sorting, log aggregation, merging sorted files, and distributed systems.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/merge-sorted-array/">Merge Sorted Array</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/">Kth Smallest Element in a Sorted Matrix</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/find-k-pairs-with-smallest-sums/">Find K Pairs with Smallest Sums</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/merge-k-sorted-lists/">Merge k Sorted Lists</a></td>
</tr>
</tbody></table>
<hr />
<h1>15. Trees &amp; Tree Traversals</h1>
<h2>Motivation</h2>
<p>Trees introduce hierarchical data. The most important skill is systematically visiting every node. The three classic DFS traversals are Preorder, Inorder, and Postorder; BFS provides Level Order traversal. Once traversal is automatic, many tree problems reduce to deciding what information should flow from a child to its parent.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-16.png" alt="DSA pattern visualization 16" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">inorder(node):
    if node == null:
        return
    inorder(node.left)
    process(node)
    inorder(node.right)

preorder(node):
    if node == null:
        return
    process(node)
    preorder(node.left)
    preorder(node.right)

postorder(node):
    if node == null:
        return
    postorder(node.left)
    postorder(node.right)
    process(node)
</code></pre>
<h2>Example</h2>
<pre><code class="language-plaintext">      4
     / \
    2   6
</code></pre>
<p>Inorder: <code>2 4 6</code>. Preorder: <code>4 2 6</code>. Postorder: <code>2 6 4</code>.</p>
<h2>Real-world application</h2>
<p>Filesystem hierarchies, organizational structures, HTML DOM, expression trees, and database indexes.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/binary-tree-inorder-traversal/">Binary Tree Inorder Traversal</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/binary-tree-level-order-traversal/">Binary Tree Level Order Traversal</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/binary-tree-right-side-view/">Binary Tree Right Side View</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/serialize-and-deserialize-binary-tree/">Serialize and Deserialize Binary Tree</a></td>
</tr>
</tbody></table>
<hr />
<h1>16. Depth First Search — DFS</h1>
<h2>Motivation</h2>
<p>DFS explores one path as deeply as possible before backtracking. It's natural for trees, graphs, connected components, maze problems, and recursive state exploration. The most important DFS skill isn't memorizing recursion — it's identifying what information should be carried through the recursive call.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-17.png" alt="DSA pattern visualization 17" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">DFS(node):
    if node is invalid or visited:
        return

    mark node visited
    process(node)

    for neighbor in node.neighbors:
        DFS(neighbor)
</code></pre>
<h2>Example</h2>
<pre><code class="language-plaintext">    A
   / \
  B   C
 / \
D   E
</code></pre>
<p>DFS could visit: <code>A → B → D → E → C</code>.</p>
<h2>Real-world application</h2>
<p>Maze solving, dependency exploration, connected components, file traversal, cycle detection, and path exploration.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/maximum-depth-of-binary-tree/">Maximum Depth of Binary Tree</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/number-of-islands/">Number of Islands</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/clone-graph/">Clone Graph</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/word-search-ii/">Word Search II</a></td>
</tr>
</tbody></table>
<hr />
<h1>17. Breadth First Search — BFS</h1>
<h2>Motivation</h2>
<p>BFS explores a graph or tree <strong>level by level</strong>, making it the natural algorithm for shortest paths in unweighted graphs, minimum number of moves, and level-order tree traversal. BFS first processes everything one step away, then everything two steps away, and so on — which gives it its shortest-path guarantee when every edge has equal cost.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-18.png" alt="DSA pattern visualization 18" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">queue = [start]
visited = {start}

while queue:
    current = queue.popFront()
    process(current)

    for neighbor in current.neighbors:
        if neighbor not in visited:
            visited.add(neighbor)
            queue.push(neighbor)
</code></pre>
<h2>Example</h2>
<p><code>A→B, A→C, B→D, C→E</code>. BFS visits: <code>A</code>, then <code>B C</code>, then <code>D E</code> — one level at a time.</p>
<h2>Real-world application</h2>
<p>Shortest route in unweighted networks, social-network degrees of separation, minimum moves in games, web crawling, and broadcasting.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/minimum-depth-of-binary-tree/">Minimum Depth of Binary Tree</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/binary-tree-level-order-traversal/">Binary Tree Level Order Traversal</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/rotting-oranges/">Rotting Oranges</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/word-ladder/">Word Ladder</a></td>
</tr>
</tbody></table>
<hr />
<h1>18. Graphs</h1>
<h2>Motivation</h2>
<p>Graphs model relationships rather than simple sequences or hierarchies. Roads connect cities, users connect to friends, services connect through dependencies, computers connect through networks. The most important graph skill is understanding representation — usually an adjacency list — then choosing the correct traversal or algorithm.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-19.png" alt="DSA pattern visualization 19" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">build adjacency list

visited = {}

DFS/BFS(start):
    mark start visited

    for neighbor in graph[start]:
        if neighbor not visited:
            visit neighbor
</code></pre>
<h2>Example</h2>
<pre><code class="language-plaintext">A -- B
|    |
C -- D
</code></pre>
<p>Adjacency list: <code>A: B,C</code>, <code>B: A,D</code>, <code>C: A,D</code>, <code>D: B,C</code>.</p>
<h2>Real-world application</h2>
<p>Social networks, computer networks, maps, recommendation systems, dependency graphs, and microservice architecture.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/find-center-of-star-graph/">Find Center of Star Graph</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/clone-graph/">Clone Graph</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/number-of-provinces/">Number of Provinces</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/critical-connections-in-a-network/">Critical Connections in a Network</a></td>
</tr>
</tbody></table>
<hr />
<h1>19. Greedy</h1>
<h2>Motivation</h2>
<p>Greedy algorithms make the best-looking choice <strong>right now</strong>, hoping a sequence of locally optimal decisions produces a globally optimal answer. The important skill is recognizing when this is actually valid — usually via an exchange argument or an invariant showing the current best choice can't hurt the final answer. Greedy problems frequently involve intervals, jumps, scheduling, resource allocation, and optimization.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-20.png" alt="DSA pattern visualization 20" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">sort or organize candidates
answer = initial state

for candidate in candidates:
    if choosing candidate is provably safe:
        choose candidate
        update answer

return answer
</code></pre>
<h2>Example</h2>
<p>Jump Game, <code>nums = [2,3,1,1,4]</code>: track the furthest reachable index, <code>maxReach = max(maxReach, i + nums[i])</code>. If <code>maxReach</code> reaches the final index, the destination is reachable.</p>
<h2>Real-world application</h2>
<p>Scheduling, resource allocation, compression, routing, task selection, and bandwidth allocation.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/assign-cookies/">Assign Cookies</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/jump-game/">Jump Game</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/gas-station/">Gas Station</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/candy/">Candy</a></td>
</tr>
</tbody></table>
<hr />
<h1>20. Trie</h1>
<h2>Motivation</h2>
<p>A Trie is a tree designed specifically for strings. Instead of comparing entire words repeatedly, it stores characters along paths, making prefix operations extremely efficient. Useful whenever a problem asks about prefixes, autocomplete, dictionaries, or searching many words simultaneously.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-21.png" alt="DSA pattern visualization 21" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">insert(word):
    node = root

    for char in word:
        if char not in node.children:
            node.children[char] = new Node()
        node = node.children[char]

    node.isWord = true

search(word):
    node = root

    for char in word:
        if char not in node.children:
            return false
        node = node.children[char]

    return node.isWord
</code></pre>
<h2>Example</h2>
<p>Insert <code>cat</code>, <code>car</code>, <code>can</code> → they share <code>ca</code>, then branch into <code>t</code>, <code>r</code>, <code>n</code>.</p>
<h2>Real-world application</h2>
<p>Autocomplete, spell checkers, search suggestions, dictionaries, prefix filtering, and IP routing concepts.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/longest-common-prefix/">Longest Common Prefix</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/implement-trie-prefix-tree/">Implement Trie (Prefix Tree)</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/design-add-and-search-words-data-structure/">Design Add and Search Words Data Structure</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/word-search-ii/">Word Search II</a></td>
</tr>
</tbody></table>
<hr />
<h1>21. Topological Sort</h1>
<h2>Motivation</h2>
<p>Topological Sort solves ordering problems where dependencies exist: if task B depends on task A, A must appear before B. The underlying structure must be a Directed Acyclic Graph. Two major approaches: DFS postorder, and Kahn's Algorithm using indegrees and a queue. Appears constantly in course scheduling, build systems, package managers, workflow engines, and deployment pipelines.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-22.png" alt="DSA pattern visualization 22" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">calculate indegree of every node
queue = all nodes with indegree 0
order = []

while queue:
    node = queue.pop()
    order.append(node)

    for neighbor in graph[node]:
        indegree[neighbor]--

        if indegree[neighbor] == 0:
            queue.push(neighbor)

if len(order) &lt; n:
    return "cycle exists"

return order
</code></pre>
<h2>Example</h2>
<p><code>A→B, A→C, B→D, C→D</code>. Valid order: <code>A → B → C → D</code> (or <code>A → C → B → D</code>).</p>
<h2>Real-world application</h2>
<p>Package installation, build systems, workflow engines, CI/CD pipelines, course prerequisites, and job dependencies.</p>
<h2>Practice</h2>
<blockquote>
<p><strong>Note on difficulty:</strong> LeetCode's cleanest Topological Sort problems start at Medium — <a href="https://leetcode.com/problems/find-eventual-safe-states/">Find Eventual Safe States</a> is sometimes mistaken for Easy but is listed as Medium. This set is Medium-heavy for the same reason as Dijkstra above. The classic Hard pick, Alien Dictionary, is Premium-only, so this set uses a free Hard problem instead.</p>
</blockquote>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/course-schedule/">Course Schedule</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/course-schedule-ii/">Course Schedule II</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/parallel-courses-iii/">Parallel Courses III</a></td>
</tr>
</tbody></table>
<hr />
<h1>22. Dijkstra's Algorithm</h1>
<h2>Motivation</h2>
<p>Dijkstra solves the shortest-path problem when edges have non-negative weights. The fundamental idea is greedy: repeatedly finalize the currently closest unprocessed node. A priority queue makes this efficient. Dijkstra connects theoretical DSA with real systems such as GPS navigation, network routing, and infrastructure optimization. Remember: standard Dijkstra requires <strong>non-negative edge weights</strong>.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-23.png" alt="DSA pattern visualization 23" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">distance[start] = 0
all other distances = infinity
heap = [(0, start)]

while heap:
    dist, node = popMin(heap)

    if dist != distance[node]:
        continue

    for neighbor, weight in graph[node]:
        newDist = dist + weight

        if newDist &lt; distance[neighbor]:
            distance[neighbor] = newDist
            push(heap, (newDist, neighbor))

return distance
</code></pre>
<h2>Example</h2>
<p><code>A --2--&gt; B</code>, <code>A --5--&gt; C</code>, <code>B --1--&gt; C</code>. From A: <code>B=2, C=5</code>. From B: <code>C=3</code>. Shortest <code>A → B → C = 3</code>.</p>
<h2>Real-world application</h2>
<p>GPS navigation, network routing, delivery optimization, telecom routing, and game pathfinding.</p>
<h2>Practice</h2>
<blockquote>
<p><strong>Note on difficulty:</strong> LeetCode does not currently have a clean, freely-accessible Easy problem that requires Dijkstra specifically — the closest fits are Medium. Rather than mislabel one, this set is deliberately Medium-heavy.</p>
</blockquote>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/network-delay-time/">Network Delay Time</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/path-with-minimum-effort/">Path With Minimum Effort</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/cheapest-flights-within-k-stops/">Cheapest Flights Within K Stops</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/swim-in-rising-water/">Swim in Rising Water</a></td>
</tr>
</tbody></table>
<hr />
<h1>23. Dynamic Programming — 1D</h1>
<h2>Motivation</h2>
<p>Dynamic Programming is used when a problem has <strong>overlapping subproblems</strong> and <strong>optimal substructure</strong>. Instead of solving the same smaller problem repeatedly, store its answer and reuse it. In 1D DP, the state often depends on one or a few previous states. The biggest conceptual shift: stop thinking recursively about every possibility, and instead ask, "What is the smallest piece of information I need to remember to solve the future?"</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-24.png" alt="DSA pattern visualization 24" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">dp[0] = base case

for i in range(1, n):
    dp[i] = best(dp[previous states])

return dp[n - 1]
</code></pre>
<h2>Example</h2>
<p>House Robber, <code>money = [2,7,9,3,1]</code>. At each house: skip it, or rob it plus the best result from two houses ago.</p>
<pre><code class="language-plaintext">dp[i] = max(dp[i-1], dp[i-2] + money[i])
</code></pre>
<h2>Real-world application</h2>
<p>Financial optimization, resource allocation, scheduling, sequence optimization, and decision systems.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/climbing-stairs/">Climbing Stairs</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/house-robber/">House Robber</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/longest-increasing-subsequence/">Longest Increasing Subsequence</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/">Best Time to Buy and Sell Stock IV</a></td>
</tr>
</tbody></table>
<hr />
<h1>24. Dynamic Programming — 2D / Grid</h1>
<h2>Motivation</h2>
<p>Two-dimensional DP is the natural extension when the answer depends on two dimensions — row and column, two strings, two sequences, or two independent states. Grid problems often have a very clean recurrence because each cell depends on neighboring cells. The critical skill is defining exactly what <code>dp[i][j]</code> means before writing any recurrence.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-25.png" alt="DSA pattern visualization 25" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">dp[0][0] = starting value

for i in rows:
    for j in columns:
        dp[i][j] = best(
            dp[i - 1][j],
            dp[i][j - 1]
        ) + current

return dp[m - 1][n - 1]
</code></pre>
<h2>Example</h2>
<pre><code class="language-plaintext">1 3
2 4
</code></pre>
<p>Minimum path sum <code>1 → 2 → 4 = 7</code>, via <code>dp[i][j] = grid[i][j] + min(dp[i-1][j], dp[i][j-1])</code>.</p>
<h2>Real-world application</h2>
<p>Route optimization, image processing, text comparison, DNA sequence comparison, and robot navigation.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/unique-paths/">Unique Paths</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/minimum-path-sum/">Minimum Path Sum</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/longest-common-subsequence/">Longest Common Subsequence</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/edit-distance/">Edit Distance</a></td>
</tr>
</tbody></table>
<hr />
<h1>25. Backtracking</h1>
<h2>Motivation</h2>
<p>Backtracking is systematic brute force. Instead of blindly generating every possibility, construct a solution incrementally. When a partial solution can no longer lead to a valid answer, immediately undo the decision and try another. Especially powerful for permutations, combinations, subsets, puzzles, constraint satisfaction, and board problems. The three operations to master: <strong>choose, explore, unchoose</strong>.</p>
<h2>Visualization</h2>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-26.png" alt="DSA pattern visualization 26" style="display:block;margin:0 auto" />

<h2>Pseudocode</h2>
<pre><code class="language-plaintext">backtrack(state):
    if solution is complete:
        save solution
        return

    for choice in choices:
        make choice
        backtrack(new state)
        undo choice
</code></pre>
<h2>Example</h2>
<p>Generate subsets of <code>[1,2]</code>: choose <code>1</code> → choose <code>2</code> → <code>[1,2]</code> → undo <code>2</code> → undo <code>1</code> → explore <code>[2]</code>. Results: <code>[], [1], [2], [1,2]</code>.</p>
<h2>Real-world application</h2>
<p>Puzzle solving, scheduling possibilities, configuration generation, password/key-space exploration, constraint satisfaction, and game search.</p>
<h2>Practice</h2>
<table>
<thead>
<tr>
<th>Difficulty</th>
<th>Problem</th>
</tr>
</thead>
<tbody><tr>
<td>Easy</td>
<td><a href="https://leetcode.com/problems/letter-case-permutation/">Letter Case Permutation</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/subsets/">Subsets</a></td>
</tr>
<tr>
<td>Medium</td>
<td><a href="https://leetcode.com/problems/combination-sum/">Combination Sum</a></td>
</tr>
<tr>
<td>Hard</td>
<td><a href="https://leetcode.com/problems/n-queens/">N-Queens</a></td>
</tr>
</tbody></table>
<hr />
<h1>Final Cheat Sheet</h1>
<table>
<thead>
<tr>
<th>#</th>
<th>Pattern</th>
<th>Main Idea</th>
</tr>
</thead>
<tbody><tr>
<td>1</td>
<td>Two Pointers</td>
<td>Move two indexes intelligently</td>
</tr>
<tr>
<td>2</td>
<td>Fast &amp; Slow Pointers</td>
<td>Detect cycles / relative positions</td>
</tr>
<tr>
<td>3</td>
<td>Sliding Window</td>
<td>Maintain a valid contiguous range</td>
</tr>
<tr>
<td>4</td>
<td>Prefix Sum</td>
<td>Precompute cumulative information</td>
</tr>
<tr>
<td>5</td>
<td>HashMap</td>
<td>O(1)-average lookup and frequency tracking</td>
</tr>
<tr>
<td>6</td>
<td>Stack</td>
<td>LIFO / nested / monotonic processing</td>
</tr>
<tr>
<td>7</td>
<td>Queue</td>
<td>FIFO / level-by-level processing</td>
</tr>
<tr>
<td>8</td>
<td>Sorting</td>
<td>Create order that enables simpler logic</td>
</tr>
<tr>
<td>9</td>
<td>Binary Search</td>
<td>Eliminate half the search space</td>
</tr>
<tr>
<td>10</td>
<td>Merge Intervals</td>
<td>Sort and combine overlapping ranges</td>
</tr>
<tr>
<td>11</td>
<td>Bitwise</td>
<td>Manipulate binary state efficiently</td>
</tr>
<tr>
<td>12</td>
<td>Heap</td>
<td>Repeatedly access min/max</td>
</tr>
<tr>
<td>13</td>
<td>Top K</td>
<td>Keep only the K candidates that matter</td>
</tr>
<tr>
<td>14</td>
<td>K-Way Merge</td>
<td>Merge multiple sorted sources</td>
</tr>
<tr>
<td>15</td>
<td>Trees</td>
<td>Hierarchical traversal</td>
</tr>
<tr>
<td>16</td>
<td>DFS</td>
<td>Explore deeply</td>
</tr>
<tr>
<td>17</td>
<td>BFS</td>
<td>Explore level by level</td>
</tr>
<tr>
<td>18</td>
<td>Graphs</td>
<td>Model relationships with nodes and edges</td>
</tr>
<tr>
<td>19</td>
<td>Greedy</td>
<td>Make provably safe local choices</td>
</tr>
<tr>
<td>20</td>
<td>Trie</td>
<td>Efficient prefix/string operations</td>
</tr>
<tr>
<td>21</td>
<td>Topological Sort</td>
<td>Order dependency graphs</td>
</tr>
<tr>
<td>22</td>
<td>Dijkstra</td>
<td>Shortest path with non-negative weights</td>
</tr>
<tr>
<td>23</td>
<td>1D DP</td>
<td>Reuse previous optimal states</td>
</tr>
<tr>
<td>24</td>
<td>2D DP</td>
<td>State depends on two dimensions</td>
</tr>
<tr>
<td>25</td>
<td>Backtracking</td>
<td>Choose → explore → undo</td>
</tr>
</tbody></table>
<h1>The Real DSA Skill</h1>
<p>The objective is <strong>not</strong>: "I solved these 100 LeetCode problems."</p>
<p>The objective is: "I can recognize which pattern this problem belongs to."</p>
<img src="https://static.sibansal.dev/the-only-25-patterns-you-need-to-master-dsa/25-DSA-patterns-27.png" alt="DSA pattern visualization 27" style="display:block;margin:0 auto" />

<p>Master these 25 patterns deeply, and DSA stops being a collection of thousands of unrelated questions. It becomes a relatively small set of ideas that keep appearing in different disguises.</p>
<h2>One final rule</h2>
<p>Do not move to the next pattern after merely watching its solution. For every pattern:</p>
<ol>
<li><p>Understand the brute-force solution.</p>
</li>
<li><p>Understand why it is too slow.</p>
</li>
<li><p>Identify the pattern.</p>
</li>
<li><p>Implement the pattern from memory.</p>
</li>
<li><p>Solve the Easy problem without help.</p>
</li>
<li><p>Solve both Medium problems.</p>
</li>
<li><p>Attempt the Hard problem.</p>
</li>
<li><p>Revisit the pattern after one week.</p>
</li>
<li><p>Solve one unseen problem using the same pattern.</p>
</li>
</ol>
<p>That is how you turn <strong>pattern recognition into interview skill</strong>.</p>
<h2>🎯 Practice the 25 DSA Patterns</h2>
<p>Reading about patterns is only the first step. The real progress comes from solving problems, revisiting patterns, and tracking what you can solve independently.</p>
<p>I created a <strong>Notion template</strong> to help you practice all 25 patterns in one place.</p>
<h3>What's inside?</h3>
<ul>
<li><p>✅ All <strong>25 DSA patterns</strong> organized in one dashboard</p>
</li>
<li><p>📊 Pattern-by-pattern mastery tracking</p>
</li>
<li><p>🧠 Main idea for each pattern</p>
</li>
<li><p>🔄 Track your progress from <strong>Not Started → Learning → Practicing → Mastered</strong></p>
</li>
<li><p>📝 A dedicated space to practice and review problems</p>
</li>
<li><p>🎯 Built around the same pattern-recognition approach used in this article</p>
</li>
</ul>
<h3>👉 <a href="https://app.notion.com/p/3b9b019b7a298043b776e0523a10b9a1?v=2ca03d048de34d3890c97ba0197ec3fc&amp;source=copy_link">Get the Free DSA Mastery 25 Notion Template</a></h3>
<blockquote>
<p><strong>Don't just solve more problems. Learn to recognize the pattern behind them.</strong></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Project Orion Case Study]]></title><description><![CDATA[Building a Scalable AI Startup Frontend Experience]]></description><link>https://blog.sibansal.dev/project-orion-case-study</link><guid isPermaLink="true">https://blog.sibansal.dev/project-orion-case-study</guid><dc:creator><![CDATA[Simran Bansal]]></dc:creator><pubDate>Sat, 23 May 2026 03:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/650e0ec30011c799f0858b61/a053cf4b-6d29-4a6f-91ad-4ba7d0268321.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Overview</h2>
<p>Project Orion was the core product development initiative for an AI startup focused on delivering an interactive and responsive AI-powered platform. The project involved designing and developing scalable frontend experiences that aligned closely with evolving client requirements while maintaining high performance and usability standards.</p>
<p>I was responsible for building the frontend architecture, implementing UI/UX workflows, and creating reusable component systems that accelerated development across the platform.</p>
<hr />
<h2>Problem Statement</h2>
<p>The startup needed a fast, scalable, and visually engaging web application that could support dynamic AI-driven interactions while maintaining a smooth user experience. Since the product evolved rapidly, the frontend system also needed to support quick iterations without sacrificing consistency or performance.</p>
<p>One of the major technical challenges involved a custom Framer Motion-powered chat interface that relied on canvas-based animations. The original implementation struggled with multiline text rendering and responsiveness, negatively impacting usability during real-time conversations.</p>
<hr />
<h2>Objectives</h2>
<ul>
<li><p>Build a modern and responsive frontend architecture</p>
</li>
<li><p>Create reusable UI components to speed up development</p>
</li>
<li><p>Improve overall application responsiveness</p>
</li>
<li><p>Deliver smooth AI-chat interactions with advanced animations</p>
</li>
<li><p>Ensure scalability for future feature expansion</p>
</li>
</ul>
<hr />
<h2>My Role</h2>
<p><strong>Frontend Developer / UI Engineer</strong></p>
<h3>Responsibilities</h3>
<ul>
<li><p>Developed frontend interfaces based on client requirements</p>
</li>
<li><p>Built reusable UI component systems</p>
</li>
<li><p>Implemented responsive layouts and interaction flows</p>
</li>
<li><p>Optimized application performance and rendering</p>
</li>
<li><p>Integrated animation systems using Framer Motion</p>
</li>
<li><p>Solved rendering limitations in the animated chat component</p>
</li>
</ul>
<hr />
<h2>Tech Stack</h2>
<ul>
<li><p>React.js</p>
</li>
<li><p>Next.js</p>
</li>
<li><p>Node.js</p>
</li>
<li><p>Tailwind CSS</p>
</li>
<li><p>Framer Motion</p>
</li>
</ul>
<hr />
<h2>Key Challenges</h2>
<h3>Rebuilding the Animated Chat Component</h3>
<p>One of the most technically demanding parts of the project was the AI chat interface that used canvas-based animations combined with Framer Motion.</p>
<p>The original implementation was designed for single-line rendering, which created issues when handling:</p>
<ul>
<li><p>Multiline user inputs</p>
</li>
<li><p>Dynamic message heights</p>
</li>
<li><p>Responsive layouts</p>
</li>
<li><p>Smooth animation synchronization</p>
</li>
</ul>
<p>To solve this, I restructured the rendering logic and rewrote parts of the component architecture to support multiline text rendering while preserving animation smoothness and responsiveness.</p>
<h3>Solution Approach</h3>
<ul>
<li><p>Redesigned the message rendering flow</p>
</li>
<li><p>Improved canvas text measurement logic</p>
</li>
<li><p>Added dynamic height calculation for chat containers</p>
</li>
<li><p>Optimized animation triggers for smoother transitions</p>
</li>
<li><p>Ensured responsiveness across different screen sizes</p>
</li>
</ul>
<p>This significantly improved the usability and stability of the chat experience without compromising visual performance.</p>
<hr />
<h2>Development Approach</h2>
<p>To support rapid product iteration, I developed reusable UI components and standardized styling patterns using Tailwind CSS. This allowed faster feature development while maintaining design consistency across the platform.</p>
<p>Performance optimization was also prioritized by minimizing unnecessary re-renders and improving frontend responsiveness.</p>
<hr />
<h2>Results &amp; Impact</h2>
<ul>
<li><p>Improved application responsiveness by 20%</p>
</li>
<li><p>Increased development speed by 30% through reusable component architecture</p>
</li>
<li><p>Enhanced stability and usability of the animated AI chat interface</p>
</li>
<li><p>Delivered scalable frontend foundations for future product growth</p>
</li>
</ul>
<hr />
<h2>Key Learnings</h2>
<ul>
<li><p>Building animation-heavy interfaces requires balancing performance with usability</p>
</li>
<li><p>Reusable design systems significantly improve scalability in startup environments</p>
</li>
<li><p>Canvas-based UI interactions demand careful handling of dynamic content rendering</p>
</li>
<li><p>Early architectural decisions directly impact iteration speed in fast-moving products</p>
</li>
</ul>
<hr />
<h2>Conclusion</h2>
<p>Project Orion provided an opportunity to work on a fast-paced AI product environment where performance, scalability, and user experience were equally important. By improving frontend architecture and solving complex UI animation challenges, the project established a stronger and more scalable foundation for the startup’s core platform.</p>
]]></content:encoded></item><item><title><![CDATA[Analytics & Report Automation Suite Case Study]]></title><description><![CDATA[Scaling Enterprise Reporting at Nokia]]></description><link>https://blog.sibansal.dev/analytics-report-automation-suite-case-study</link><guid isPermaLink="true">https://blog.sibansal.dev/analytics-report-automation-suite-case-study</guid><dc:creator><![CDATA[Simran Bansal]]></dc:creator><pubDate>Sat, 23 May 2026 03:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/650e0ec30011c799f0858b61/26447b03-a69d-46d3-91d5-e71a90cc58f8.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Overview</h2>
<p>The Analytics &amp; Report Automation Suite was developed to streamline large-scale reporting and data processing workflows at Nokia. The platform focused on automating repetitive analytics operations, reducing reporting delays, and improving the efficiency of handling high-volume datasets.</p>
<p>The project involved building scalable data pipelines, optimizing query execution, and automating report generation processes used across internal operational workflows.</p>
<hr />
<h2>Problem Statement</h2>
<p>The existing reporting workflows relied heavily on manual intervention and fragmented processing pipelines, resulting in:</p>
<ul>
<li><p>Slow reporting turnaround times</p>
</li>
<li><p>Inefficient handling of large datasets</p>
</li>
<li><p>High operational overhead for recurring reports</p>
</li>
<li><p>Delays in business decision-making due to inconsistent data availability</p>
</li>
</ul>
<p>As data volumes continued to grow beyond millions of entries, maintaining performance and reliability became increasingly difficult.</p>
<hr />
<h2>Objectives</h2>
<ul>
<li><p>Automate repetitive reporting workflows</p>
</li>
<li><p>Improve large-scale data processing efficiency</p>
</li>
<li><p>Reduce report generation turnaround time</p>
</li>
<li><p>Build scalable and maintainable analytics pipelines</p>
</li>
<li><p>Enable faster access to operational insights</p>
</li>
</ul>
<hr />
<h2>My Role</h2>
<p><strong>Software Engineer / Data Automation Developer</strong></p>
<h3>Responsibilities</h3>
<ul>
<li><p>Developed and optimized analytics workflows</p>
</li>
<li><p>Automated enterprise reporting pipelines</p>
</li>
<li><p>Wrote and optimized SQL and Hive queries</p>
</li>
<li><p>Processed and transformed large-scale datasets</p>
</li>
<li><p>Improved backend data handling efficiency</p>
</li>
<li><p>Maintained Linux-based data processing environments</p>
</li>
</ul>
<hr />
<h2>Tech Stack</h2>
<ul>
<li><p>Python</p>
</li>
<li><p>Hive</p>
</li>
<li><p>SQL</p>
</li>
<li><p>Linux</p>
</li>
</ul>
<hr />
<h2>Key Challenges</h2>
<h3>Processing Large Datasets Efficiently</h3>
<p>One of the biggest challenges was handling datasets containing high volume data while maintaining acceptable processing and reporting times.</p>
<p>The original workflows suffered from:</p>
<ul>
<li><p>Slow query execution</p>
</li>
<li><p>Resource-heavy data transformations</p>
</li>
<li><p>Repeated manual reporting tasks</p>
</li>
<li><p>Inefficient aggregation pipelines</p>
</li>
</ul>
<h3>Solution Approach</h3>
<p>To improve performance and scalability, I focused on optimizing both the data processing layer and the automation workflows.</p>
<p>Key improvements included:</p>
<ul>
<li><p>Refactoring complex SQL and Hive queries</p>
</li>
<li><p>Reducing redundant processing operations</p>
</li>
<li><p>Automating recurring report generation tasks</p>
</li>
<li><p>Optimizing data transformation workflows</p>
</li>
<li><p>Improving script execution efficiency in Linux environments</p>
</li>
</ul>
<p>These optimizations significantly reduced processing overhead and improved overall reporting reliability.</p>
<hr />
<h2>Development Approach</h2>
<p>The platform was designed with automation and scalability as primary goals. By introducing reusable processing workflows and streamlining reporting logic, the system became more efficient and easier to maintain.</p>
<p>A strong emphasis was placed on performance optimization, particularly for large-scale data operations where query efficiency directly impacted turnaround times.</p>
<hr />
<h2>Results &amp; Impact</h2>
<ul>
<li><p>Reduced reporting turnaround time by 80%</p>
</li>
<li><p>Improved data processing efficiency by 60% for datasets exceeding 1M entries</p>
</li>
<li><p>Minimized manual effort through automation</p>
</li>
<li><p>Improved reliability and consistency of enterprise reporting workflows</p>
</li>
</ul>
<hr />
<h2>Key Learnings</h2>
<ul>
<li><p>Query optimization plays a critical role in large-scale analytics systems</p>
</li>
<li><p>Automation significantly improves operational efficiency in enterprise environments</p>
</li>
<li><p>Efficient data pipeline design is essential for scaling reporting systems</p>
</li>
<li><p>Small performance improvements compound significantly when processing millions of records</p>
</li>
</ul>
<hr />
<h2>Conclusion</h2>
<p>The Analytics &amp; Report Automation Suite helped modernize enterprise reporting workflows by introducing scalable automation and optimized data processing pipelines. Through performance-focused engineering and workflow automation, the project significantly improved reporting speed, operational efficiency, and data accessibility across large-scale analytics operations.</p>
]]></content:encoded></item><item><title><![CDATA[Spring Boot API Modernization Case Study ]]></title><description><![CDATA[Modernizing Enterprise Microservices at Nokia]]></description><link>https://blog.sibansal.dev/spring-boot-api-modernization-case-study</link><guid isPermaLink="true">https://blog.sibansal.dev/spring-boot-api-modernization-case-study</guid><dc:creator><![CDATA[Simran Bansal]]></dc:creator><pubDate>Sat, 23 May 2026 03:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/650e0ec30011c799f0858b61/dd7244da-6a84-4445-904d-b804ac853591.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Overview</h2>
<p>The Spring Boot API Modernization project focused on upgrading and modernizing an existing API aggregation system at Nokia. The initiative aimed to improve maintainability, enhance security, and expand platform capabilities while ensuring backward compatibility for existing consumers.</p>
<p>The project involved upgrading legacy dependencies, improving API documentation standards using Swagger 3, and enhancing the microservices architecture to support future scalability and development.</p>
<hr />
<h2>Problem Statement</h2>
<p>The existing API aggregation system had accumulated outdated dependencies and legacy configurations over time, leading to:</p>
<ul>
<li><p>Security vulnerabilities from deprecated libraries</p>
</li>
<li><p>Maintenance challenges across services</p>
</li>
<li><p>Limited scalability for new feature development</p>
</li>
<li><p>Inconsistent API documentation</p>
</li>
<li><p>Risks of breaking existing client integrations during upgrades</p>
</li>
</ul>
<p>The challenge was to modernize the platform without disrupting existing API consumers and enterprise workflows.</p>
<hr />
<h2>Objectives</h2>
<ul>
<li><p>Upgrade legacy Spring Boot dependencies</p>
</li>
<li><p>Resolve existing security vulnerabilities</p>
</li>
<li><p>Improve API maintainability and scalability</p>
</li>
<li><p>Introduce modern API documentation standards</p>
</li>
<li><p>Expand platform functionality while preserving backward compatibility</p>
</li>
</ul>
<hr />
<h2>My Role</h2>
<p><strong>Backend Developer / Software Engineer</strong></p>
<h3>Responsibilities</h3>
<ul>
<li><p>Modernized Spring Boot services and dependencies</p>
</li>
<li><p>Resolved dependency conflicts and security issues</p>
</li>
<li><p>Integrated Swagger 3 for API documentation</p>
</li>
<li><p>Enhanced microservices functionality</p>
</li>
<li><p>Maintained compatibility for existing API consumers</p>
</li>
<li><p>Supported system stability during migration and upgrades</p>
</li>
</ul>
<hr />
<h2>Tech Stack</h2>
<ul>
<li><p>Spring Boot</p>
</li>
<li><p>Java</p>
</li>
<li><p>Swagger 3</p>
</li>
<li><p>Microservices Architecture</p>
</li>
<li><p>REST APIs</p>
</li>
</ul>
<hr />
<h2>Key Challenges</h2>
<h3>Maintaining Backward Compatibility During Modernization</h3>
<p>One of the biggest challenges was upgrading the system architecture and dependencies without affecting existing API consumers that relied on legacy endpoints.</p>
<p>The platform supported multiple integrations, making stability and compatibility critical throughout the modernization process.</p>
<h3>Solution Approach</h3>
<p>To minimize disruption and ensure smooth migration, I implemented a phased modernization strategy that included:</p>
<ul>
<li><p>Carefully upgrading dependencies incrementally</p>
</li>
<li><p>Resolving deprecated library and security vulnerabilities</p>
</li>
<li><p>Introducing Swagger 3 for standardized API documentation</p>
</li>
<li><p>Expanding microservice functionality while preserving legacy behavior</p>
</li>
<li><p>Testing existing endpoints extensively to prevent regressions</p>
</li>
</ul>
<p>This approach allowed the platform to evolve technically while maintaining operational continuity for dependent systems.</p>
<hr />
<h2>Development Approach</h2>
<p>The modernization effort focused on balancing technical improvements with production stability. Security upgrades, maintainability, and extensibility were prioritized while ensuring that existing integrations remained unaffected.</p>
<p>A modular microservices-based structure also improved future scalability and simplified ongoing development efforts.</p>
<hr />
<h2>Results &amp; Impact</h2>
<ul>
<li><p>Upgraded outdated dependencies and resolved security vulnerabilities</p>
</li>
<li><p>Expanded platform functionality without breaking existing endpoints</p>
</li>
<li><p>Improved API maintainability and documentation standards</p>
</li>
<li><p>Strengthened long-term scalability of the microservices ecosystem</p>
</li>
</ul>
<hr />
<h2>Key Learnings</h2>
<ul>
<li><p>Enterprise modernization projects require careful balance between innovation and stability</p>
</li>
<li><p>Backward compatibility is critical in large-scale API ecosystems</p>
</li>
<li><p>Incremental upgrades reduce migration risks in production environments</p>
</li>
<li><p>Standardized API documentation improves developer experience and maintainability</p>
</li>
</ul>
<hr />
<h2>Conclusion</h2>
<p>The Spring Boot API Modernization project successfully transformed a legacy API aggregation system into a more secure, maintainable, and scalable platform. By modernizing dependencies, improving documentation, and enhancing the microservices architecture, the project strengthened the long-term reliability and extensibility of Nokia’s backend systems.</p>
]]></content:encoded></item><item><title><![CDATA[ClickHouse Deployment on Kubernetes Case Study]]></title><description><![CDATA[Building Scalable Analytics Infrastructure]]></description><link>https://blog.sibansal.dev/clickhouse-deployment-on-kubernetes-case-study</link><guid isPermaLink="true">https://blog.sibansal.dev/clickhouse-deployment-on-kubernetes-case-study</guid><dc:creator><![CDATA[Simran Bansal]]></dc:creator><pubDate>Sat, 23 May 2026 03:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/650e0ec30011c799f0858b61/461a5945-61bf-4d2d-a439-530ef665426d.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Overview</h2>
<p>This project focused on deploying and managing a high-performance ClickHouse OLAP database infrastructure on Kubernetes for large-scale analytics workloads. The goal was to create a scalable, containerized deployment workflow capable of supporting multiple analytics projects with improved reliability, deployment speed, and operational efficiency.</p>
<p>The project involved infrastructure automation, Kubernetes orchestration, and optimization of deployment workflows for analytics-focused applications.</p>
<hr />
<h2>Problem Statement</h2>
<p>The existing deployment workflows for analytics services lacked scalability and operational consistency. Managing multiple containerized analytics projects introduced challenges such as:</p>
<ul>
<li><p>Slow deployment cycles</p>
</li>
<li><p>Complex infrastructure setup processes</p>
</li>
<li><p>Resource management inefficiencies</p>
</li>
<li><p>Difficulty scaling analytics workloads</p>
</li>
<li><p>Inconsistent deployment configurations across projects</p>
</li>
</ul>
<p>As the number of analytics services increased, a more standardized and scalable infrastructure approach became necessary.</p>
<hr />
<h2>Objectives</h2>
<ul>
<li><p>Deploy ClickHouse on Kubernetes for scalable OLAP workloads</p>
</li>
<li><p>Improve deployment speed and infrastructure consistency</p>
</li>
<li><p>Streamline workflows for containerized analytics projects</p>
</li>
<li><p>Build reusable deployment configurations</p>
</li>
<li><p>Enhance scalability and operational efficiency</p>
</li>
</ul>
<hr />
<h2>My Role</h2>
<p><strong>Infrastructure Engineer / DevOps Engineer</strong></p>
<h3>Responsibilities</h3>
<ul>
<li><p>Designed and deployed Kubernetes-based infrastructure</p>
</li>
<li><p>Configured ClickHouse deployments for analytics workloads</p>
</li>
<li><p>Automated deployment workflows</p>
</li>
<li><p>Optimized container orchestration processes</p>
</li>
<li><p>Supported scalability and infrastructure reliability</p>
</li>
<li><p>Standardized deployment practices across projects</p>
</li>
</ul>
<hr />
<h2>Tech Stack</h2>
<ul>
<li><p>Kubernetes</p>
</li>
<li><p>ClickHouse</p>
</li>
<li><p>Docker</p>
</li>
<li><p>Linux</p>
</li>
<li><p>Containerized Infrastructure</p>
</li>
</ul>
<hr />
<h2>Key Challenges</h2>
<h3>Scaling Analytics Infrastructure Efficiently</h3>
<p>One of the major challenges was building a deployment workflow that could reliably support multiple analytics projects while maintaining performance and operational consistency.</p>
<p>The infrastructure needed to handle:</p>
<ul>
<li><p>High-performance OLAP workloads</p>
</li>
<li><p>Multiple containerized deployments</p>
</li>
<li><p>Faster provisioning cycles</p>
</li>
<li><p>Scalable resource allocation</p>
</li>
<li><p>Reliable orchestration across environments</p>
</li>
</ul>
<h3>Solution Approach</h3>
<p>To improve deployment efficiency and scalability, I focused on standardizing infrastructure workflows and optimizing Kubernetes deployment processes.</p>
<p>Key improvements included:</p>
<ul>
<li><p>Creating reusable deployment configurations</p>
</li>
<li><p>Automating container orchestration workflows</p>
</li>
<li><p>Optimizing Kubernetes resource management</p>
</li>
<li><p>Streamlining deployment pipelines for analytics services</p>
</li>
<li><p>Improving environment consistency across projects</p>
</li>
</ul>
<p>This approach reduced deployment overhead and simplified infrastructure management for analytics applications.</p>
<hr />
<h2>Development Approach</h2>
<p>The project emphasized scalability, automation, and operational reliability. Kubernetes-based orchestration allowed better resource utilization and simplified deployment management for containerized analytics workloads.</p>
<p>A reusable deployment architecture also enabled faster onboarding for new analytics projects while reducing infrastructure maintenance complexity.</p>
<hr />
<h2>Results &amp; Impact</h2>
<ul>
<li><p>Optimized deployment times by 30%</p>
</li>
<li><p>Successfully deployed workflows for 10+ containerized analytics projects</p>
</li>
<li><p>Improved infrastructure scalability and consistency</p>
</li>
<li><p>Reduced operational overhead through deployment automation</p>
</li>
</ul>
<hr />
<h2>Key Learnings</h2>
<ul>
<li><p>Kubernetes significantly improves scalability for analytics infrastructure</p>
</li>
<li><p>Standardized deployment workflows reduce operational complexity</p>
</li>
<li><p>Automation is critical for managing multiple containerized projects efficiently</p>
</li>
<li><p>Infrastructure optimization directly impacts deployment reliability and developer productivity</p>
</li>
</ul>
<hr />
<h2>Conclusion</h2>
<p>The ClickHouse Deployment on Kubernetes project established a scalable and efficient infrastructure foundation for analytics workloads. By automating deployments and optimizing Kubernetes orchestration, the project improved deployment speed, operational consistency, and scalability across multiple containerized analytics platforms.</p>
]]></content:encoded></item><item><title><![CDATA[Learn GIT in a Day]]></title><description><![CDATA[A Comprehensive One-Day Crash Course on GIT]]></description><link>https://blog.sibansal.dev/learn-git-in-a-day</link><guid isPermaLink="true">https://blog.sibansal.dev/learn-git-in-a-day</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Simran Bansal]]></dc:creator><pubDate>Sat, 17 Feb 2024 08:20:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1708113389318/a4fa718c-a3e7-4d92-9b35-843fd2dfa790.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Welcome, everyone, to this one-day crash course on GIT! Whether you're new to version control or looking to refresh your skills, get ready for an exciting journey packed with learning and exploration.</p>
<p>Today, we'll cover the essentials of Git through a series of 18 exercises. Don't worry if you're new to this – I'll take it step by step, ensuring you grasp each concept with ease.</p>
<p>Let's dive in! Below, you'll find the exercises designed to help you understand Git fundamentals. Feel free to move at your own pace, and remember, there's no rush!</p>
<h3 id="heading-weapons-you-need-in-your-arsenal">Weapons you need in your arsenal</h3>
<ol>
<li><p>GIT Installed on your system (<a target="_blank" href="https://git-scm.com/downloads">Download Here</a>).</p>
</li>
<li><p>Any IDE (VS Code is recommended).</p>
</li>
<li><p>An account on Github (<a target="_blank" href="https://github.com/">Create Here</a>).</p>
</li>
</ol>
<h3 id="heading-git-exercises-for-college-students">Git Exercises for College Students</h3>
<h4 id="heading-exercise-1-initializing-a-repository">Exercise 1: Initializing a Repository</h4>
<ol>
<li><p><strong>Description:</strong> Initialize a new Git repository and create a <a target="_blank" href="http://Readme.md"><code>Readme.md</code></a> file.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Open your terminal.</p>
</li>
<li><p>Navigate to the desired directory for your project.</p>
</li>
<li><p>Run the following commands:</p>
<pre><code class="lang-bash">  git init
  <span class="hljs-built_in">echo</span> <span class="hljs-string">"# My Project"</span> &gt; Readme.md
  git add Readme.md
  git commit -m <span class="hljs-string">"Initial commit: Add Readme.md"</span>
</code></pre>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-2-making-changes">Exercise 2: Making Changes</h4>
<ol>
<li><p><strong>Description:</strong> Make changes to the <a target="_blank" href="http://Readme.md"><code>Readme.md</code></a> file and commit them.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Open <a target="_blank" href="http://Readme.md"><code>Readme.md</code></a> in your preferred text editor.</p>
</li>
<li><p>Add some text or make modifications to the file.</p>
</li>
<li><p>Save the changes.</p>
</li>
<li><p>Run the following commands:</p>
<pre><code class="lang-bash">  git add Readme.md
  git commit -m <span class="hljs-string">"Update Readme.md: Add project description"</span>
</code></pre>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-3-viewing-changes">Exercise 3: Viewing Changes</h4>
<ol>
<li><p><strong>Description:</strong> View the differences between commits.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Make additional changes to the <a target="_blank" href="http://Readme.md"><code>Readme.md</code></a> file.</p>
</li>
<li><p>Save the changes.</p>
</li>
<li><p>Run the following command to view the differences:</p>
<pre><code class="lang-bash">  git diff commit_id_1 commit_id_2
</code></pre>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-4-branching">Exercise 4: Branching</h4>
<ol>
<li><p><strong>Description:</strong> Create a new branch and switch to it.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Run the following commands:</p>
<pre><code class="lang-bash">  git branch feature
  git checkout feature
</code></pre>
</li>
<li><p>Make changes to the <a target="_blank" href="http://Readme.md"><code>Readme.md</code></a> file within the <code>feature</code> branch.</p>
</li>
<li><p>Add and commit the changes.</p>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-5-merging">Exercise 5: Merging</h4>
<ol>
<li><p><strong>Description:</strong> Merge changes from the <code>feature</code> branch into the <code>main</code> branch.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Switch back to the <code>main</code> branch:</p>
<pre><code class="lang-bash">  git checkout main
</code></pre>
</li>
<li><p>Merge changes from the <code>feature</code> branch:</p>
<pre><code class="lang-bash">  git merge feature
</code></pre>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-6-resolving-conflicts">Exercise 6: Resolving Conflicts</h4>
<ol>
<li><p><strong>Description:</strong> Simulate a merge conflict and resolve it.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Make conflicting changes to the <a target="_blank" href="http://Readme.md"><code>Readme.md</code></a> file in both the <code>main</code> and <code>feature</code> branches.</p>
</li>
<li><p>Attempt to merge the <code>feature</code> branch into <code>main</code>:</p>
<pre><code class="lang-bash">  git merge feature
</code></pre>
</li>
<li><p>Resolve the conflicts in the file.</p>
</li>
<li><p>Add and commit the resolved file.</p>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-7-remote-repositories">Exercise 7: Remote Repositories</h4>
<ol>
<li><p><strong>Description:</strong> Connect your local repository to a remote repository on GitHub.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Create a new repository on GitHub.</p>
</li>
<li><p>Follow the instructions on GitHub to add the remote repository URL to your local repository.</p>
</li>
<li><p>Push your local changes to the remote repository:</p>
<pre><code class="lang-bash">  git push origin main
</code></pre>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-8-cloning">Exercise 8: Cloning</h4>
<ol>
<li><p><strong>Description:</strong> Clone a repository from GitHub to your local machine.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Find a repository on GitHub that you want to clone.</p>
</li>
<li><p>Copy the repository URL.</p>
</li>
<li><p>Open your terminal and navigate to the directory where you want to clone the repository.</p>
</li>
<li><p>Run the following command:</p>
<pre><code class="lang-bash">  git <span class="hljs-built_in">clone</span> &lt;repository_url&gt;
</code></pre>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-9-pulling-changes">Exercise 9: Pulling Changes</h4>
<ol>
<li><p><strong>Description:</strong> Fetch and merge changes from a remote repository.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Navigate to your local repository.</p>
</li>
<li><p>Run the following command to fetch and merge changes from the remote repository:</p>
<pre><code class="lang-bash">  git pull origin main
</code></pre>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-10-collaboration">Exercise 10: Collaboration</h4>
<ol>
<li><p><strong>Description:</strong> Collaborate with a classmate on a Git repository.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Find a classmate to collaborate with.</p>
</li>
<li><p>Add them as a collaborator on your GitHub repository.</p>
</li>
<li><p>Have your classmate clone the repository to their local machine.</p>
</li>
<li><p>Make changes to the repository and push them to GitHub.</p>
</li>
<li><p>Fetch and merge their changes into your local repository.</p>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-11-undoing-changes">Exercise 11: Undoing Changes</h4>
<ol>
<li><p><strong>Description:</strong> Undo changes made to a file and discard them.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Make changes to the <a target="_blank" href="http://Readme.md"><code>Readme.md</code></a> file.</p>
</li>
<li><p>Run the following command to discard the changes and revert to the last committed state:</p>
<pre><code class="lang-bash">  git checkout -- Readme.md
</code></pre>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-12-stashing-changes">Exercise 12: Stashing Changes</h4>
<ol>
<li><p><strong>Description:</strong> Temporarily store changes to work on something else.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Make changes to the <a target="_blank" href="http://Readme.md"><code>Readme.md</code></a> file.</p>
</li>
<li><p>Run the following command to stash the changes:</p>
<pre><code class="lang-bash">  git stash
</code></pre>
</li>
<li><p>Make additional changes or switch branches.</p>
</li>
<li><p>Retrieve the stashed changes:</p>
<pre><code class="lang-bash">  git stash pop
</code></pre>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-13-rebasing">Exercise 13: Rebasing</h4>
<ol>
<li><p><strong>Description:</strong> Reapply commits on top of another branch.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Create a new branch:</p>
<pre><code class="lang-bash">  git branch experiment
  git checkout experiment
</code></pre>
</li>
<li><p>Make changes and commit them.</p>
</li>
<li><p>Switch back to the <code>main</code> branch:</p>
<pre><code class="lang-bash">  git checkout main
</code></pre>
</li>
<li><p>Run the following command to rebase the <code>experiment</code> branch onto <code>main</code>:</p>
<pre><code class="lang-bash">  git rebase experiment
</code></pre>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-14-viewing-history">Exercise 14: Viewing History</h4>
<ol>
<li><p><strong>Description:</strong> View commit history and explore different options.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Run the following command to view commit history:</p>
<pre><code class="lang-bash">  git <span class="hljs-built_in">log</span>
</code></pre>
</li>
<li><p>Explore different options such as formatting, filtering by author, date range, etc.</p>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-15-tagging-releases">Exercise 15: Tagging Releases</h4>
<ol>
<li><p><strong>Description:</strong> Tag a specific commit as a release.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Identify the commit you want to tag:</p>
<pre><code class="lang-bash">  git <span class="hljs-built_in">log</span>
</code></pre>
</li>
<li><p>Run the following command to tag the commit:</p>
<pre><code class="lang-bash">  git tag v1.0 &lt;commit_id&gt;
</code></pre>
</li>
<li><p>Push the tag to the remote repository:</p>
<pre><code class="lang-bash">  git push origin v1.0
</code></pre>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-16-collaborative-workflow">Exercise 16: Collaborative Workflow</h4>
<ol>
<li><p><strong>Description:</strong> Simulate a typical collaborative workflow with branching and merging.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Divide into pairs (A and B).</p>
</li>
<li><p>A creates a new branch, makes changes, and commits them.</p>
</li>
<li><p>A pushes the branch to the remote repository.</p>
</li>
<li><p>B pulls the branch, reviews the changes, and merges them into the <code>main</code> branch.</p>
</li>
<li><p>Switch roles and repeat the process.</p>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-17-gitignore">Exercise 17: Gitignore</h4>
<ol>
<li><p><strong>Description:</strong> Ignore certain files or directories from version control.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Create a <code>.gitignore</code> file in the root of your repository.</p>
</li>
<li><p>Add file patterns or directory names to ignore.</p>
</li>
<li><p>Commit the <code>.gitignore</code> file.</p>
</li>
<li><p>Verify that ignored files are not included in Git's tracking.</p>
</li>
</ul>
</li>
</ol>
<h4 id="heading-exercise-18-git-hooks">Exercise 18: Git Hooks</h4>
<ol>
<li><p><strong>Description:</strong> Automate tasks with Git hooks.</p>
</li>
<li><p><strong>Steps:</strong></p>
<ul>
<li><p>Create a Git hook script (e.g., pre-commit, post-commit) in the <code>.git/hooks</code> directory of your repository.</p>
</li>
<li><p>Add desired commands or scripts to the hook.</p>
</li>
<li><p>Make changes and commit to trigger the hook.</p>
</li>
<li><p>Verify that the hook executes the specified tasks.</p>
</li>
</ul>
</li>
</ol>
<p>Congratulations on embarking on this learning journey! By the end of the day, you'll have a solid foundation in Git and be well-prepared to continue exploring on your own.</p>
<p>Thank you for joining us today. Let's make the most of our time and dive into the exciting world of version control with Git!</p>
]]></content:encoded></item><item><title><![CDATA[Explained and Solved: Rotate Array: DSA Problem]]></title><description><![CDATA[DSA Practice Series]]></description><link>https://blog.sibansal.dev/explained-and-solved-rotate-array-dsa-problem</link><guid isPermaLink="true">https://blog.sibansal.dev/explained-and-solved-rotate-array-dsa-problem</guid><category><![CDATA[data structures]]></category><category><![CDATA[array]]></category><category><![CDATA[Practice coding]]></category><category><![CDATA[coding]]></category><dc:creator><![CDATA[Simran Bansal]]></dc:creator><pubDate>Thu, 07 Dec 2023 20:47:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1701982871514/f25d2d13-79d6-4bc3-ae4e-fa62ffe0ffff.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-problem">Problem</h1>
<p>Given an integer array <code>nums</code>, rotate the array to the right by <code>k</code> steps, where <code>k</code> is non-negative.</p>
<p><strong>Example 1:</strong></p>
<pre><code class="lang-java">Input: nums = [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>,<span class="hljs-number">6</span>,<span class="hljs-number">7</span>], k = <span class="hljs-number">3</span>
Output: [<span class="hljs-number">5</span>,<span class="hljs-number">6</span>,<span class="hljs-number">7</span>,<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>]
Explanation:
rotate <span class="hljs-number">1</span> steps to the right: [<span class="hljs-number">7</span>,<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>,<span class="hljs-number">6</span>]
rotate <span class="hljs-number">2</span> steps to the right: [<span class="hljs-number">6</span>,<span class="hljs-number">7</span>,<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>]
rotate <span class="hljs-number">3</span> steps to the right: [<span class="hljs-number">5</span>,<span class="hljs-number">6</span>,<span class="hljs-number">7</span>,<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>]
</code></pre>
<p><strong>Example 2:</strong></p>
<pre><code class="lang-java">Input: nums = [-<span class="hljs-number">1</span>,-<span class="hljs-number">100</span>,<span class="hljs-number">3</span>,<span class="hljs-number">99</span>], k = <span class="hljs-number">2</span>
Output: [<span class="hljs-number">3</span>,<span class="hljs-number">99</span>,-<span class="hljs-number">1</span>,-<span class="hljs-number">100</span>]
Explanation: 
rotate <span class="hljs-number">1</span> steps to the right: [<span class="hljs-number">99</span>,-<span class="hljs-number">1</span>,-<span class="hljs-number">100</span>,<span class="hljs-number">3</span>]
rotate <span class="hljs-number">2</span> steps to the right: [<span class="hljs-number">3</span>,<span class="hljs-number">99</span>,-<span class="hljs-number">1</span>,-<span class="hljs-number">100</span>]
</code></pre>
<p><strong>Constraints:</strong></p>
<ul>
<li><p><code>1 &lt;= nums.length &lt;= 10&lt;sup&gt;5&lt;/sup&gt;</code></p>
</li>
<li><p><code>-2&lt;sup&gt;31&lt;/sup&gt; &lt;= nums[i] &lt;= 2&lt;sup&gt;31&lt;/sup&gt; - 1</code></p>
</li>
<li><p><code>0 &lt;= k &lt;= 10&lt;sup&gt;5&lt;/sup&gt;</code></p>
</li>
</ul>
<h1 id="heading-solution">Solution</h1>
<h2 id="heading-intuition"><strong>Intuition</strong></h2>
<p>If I have [1,2,3,4,5,6,7] and k=3 then I need to shift 3 elements cyclically.</p>
<p>With that, my final result will be [5,6,7,1,2,3,4]</p>
<p>Initially, I was solving it by traditional approach like single shift, which took me O(kN) time.</p>
<p>To think differently, I have tried to understand the approach in a bottom-up approach: solution to the problem.</p>
<p>If I see [5,6,7] that is the k partition, [1,2,3,4] that is shifted element partition, if I reverse [1,2,3,4] I will get [4,3,2,1].</p>
<p>If I look whole combined array at this step, then it will be [7,6,5,4,3,2,1] which is, yes, you are right, the reversal of the original array.</p>
<p>So here I decode it like this:</p>
<ul>
<li><p>Go from [1,2,3,4,5,6,7] to [7,6,5,4,3,2,1]: Reverse the whole array.</p>
</li>
<li><p>Now I need to reverse [7,6,5] which is the last k element of the array, it will seem as if we rotate them when this subpartition has been swapped. So we will have: [5,6,7,4,3,2,1]</p>
</li>
<li><p>Now look carefully you will observe [5,6,7] are at their place. You only make [4,3,2,1] right.</p>
</li>
<li><p>Again you are correct, reverse this sub-partition: [4,3,2,1] -&gt; [1,2,3,4]</p>
</li>
<li><p>Voila, we have [5,6,7,1,2,3,4], our exact answer.</p>
</li>
</ul>
<h2 id="heading-approach"><strong>Approach</strong></h2>
<ol>
<li><p>Reverse the whole array.</p>
</li>
<li><p>Reverse up to k.</p>
</li>
<li><p>Reverse from k+1 to the last index.</p>
</li>
</ol>
<h2 id="heading-complexity"><strong>Complexity</strong></h2>
<ul>
<li><p>Time complexity: O(N)</p>
</li>
<li><p>Space complexity: O(1)</p>
</li>
</ul>
<h2 id="heading-code"><strong>Code</strong></h2>
<h3 id="heading-java">Java</h3>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Solution</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">reverse</span><span class="hljs-params">(<span class="hljs-keyword">int</span>[] nums, <span class="hljs-keyword">int</span> start, <span class="hljs-keyword">int</span> end)</span>
    </span>{
        <span class="hljs-keyword">while</span>(start&lt;end)
        {
          nums[end] = nums[start]+nums[end]-(nums[start]=nums[end]);
          start++;
          end--;
        }
    }
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">rotate</span><span class="hljs-params">(<span class="hljs-keyword">int</span>[] nums, <span class="hljs-keyword">int</span> k)</span> </span>{
        k=k%nums.length;
        reverse(nums, <span class="hljs-number">0</span>, nums.length-<span class="hljs-number">1</span>);
        reverse(nums, <span class="hljs-number">0</span>, k-<span class="hljs-number">1</span>);
        reverse(nums, k, nums.length-<span class="hljs-number">1</span>);
    }
}
</code></pre>
<h3 id="heading-python">Python</h3>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Solution</span>:

    <span class="hljs-title">def</span> <span class="hljs-title">reverse</span>(<span class="hljs-title">self</span>, <span class="hljs-title">nums</span>: <span class="hljs-title">List</span>[<span class="hljs-title">int</span>], <span class="hljs-title">start</span>: <span class="hljs-title">int</span>, <span class="hljs-title">end</span>: <span class="hljs-title">int</span>) -&gt; <span class="hljs-title">None</span>:
      <span class="hljs-title">while</span> <span class="hljs-title">start</span>&lt;<span class="hljs-title">end</span>:
        <span class="hljs-title">nums</span>[<span class="hljs-title">start</span>], <span class="hljs-title">nums</span>[<span class="hljs-title">end</span>] </span>= nums[end], nums[start]
        start+=<span class="hljs-number">1</span>
        end-=<span class="hljs-number">1</span>

    <span class="hljs-function">def <span class="hljs-title">rotate</span><span class="hljs-params">(self, nums: List[<span class="hljs-keyword">int</span>], k: <span class="hljs-keyword">int</span>)</span> -&gt; None:
      k</span>=k%len(nums)
      self.reverse(nums, <span class="hljs-number">0</span>, len(nums)-<span class="hljs-number">1</span>)
      self.reverse(nums, <span class="hljs-number">0</span>, k-<span class="hljs-number">1</span>)
      self.reverse(nums, k, len(nums)-<span class="hljs-number">1</span>)
</code></pre>
<p>I have also posted the same solution on Leetcode: <a target="_blank" href="https://leetcode.com/problems/rotate-array/solutions/4376260/fully-explained-readable-and-100-efficient-java-solution/">https://leetcode.com/problems/rotate-array/solutions/4376260/fully-explained-readable-and-100-efficient-java-solution/</a></p>
]]></content:encoded></item></channel></rss>