<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Quipoin</title>
    <description>The latest articles on Forem by Quipoin (@quipoin_a9cb84280f6225b1e).</description>
    <link>https://forem.com/quipoin_a9cb84280f6225b1e</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3592134%2F7af2047e-ad93-4d4f-bb28-726999e59e47.png</url>
      <title>Forem: Quipoin</title>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/quipoin_a9cb84280f6225b1e"/>
    <language>en</language>
    <item>
      <title>Two Pointer Technique in Java: The Trick That Replaces Nested Loops</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Fri, 01 May 2026 09:04:04 +0000</pubDate>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e/two-pointer-technique-in-java-the-trick-that-replaces-nested-loops-20on</link>
      <guid>https://forem.com/quipoin_a9cb84280f6225b1e/two-pointer-technique-in-java-the-trick-that-replaces-nested-loops-20on</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8orcc2kfffkolctjk1fk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8orcc2kfffkolctjk1fk.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Many array problems look like they need nested loops.&lt;/p&gt;

&lt;p&gt;That means O(n²) time.&lt;/p&gt;

&lt;p&gt;But with one simple idea — Two Pointers —&lt;br&gt;
you can often reduce it to O(n).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Two Pointer Technique?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of using one loop,&lt;br&gt;
you use two indices (pointers):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;From opposite ends&lt;/li&gt;
&lt;li&gt;Or moving in the same direction&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Helps reduce unnecessary work&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1: Two Sum (Sorted Array)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;public static int[] twoSumSorted(int[] arr, int target) {&lt;br&gt;
    int left = 0, right = arr.length - 1;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (left &amp;lt; right) {
    int sum = arr[left] + arr[right];

    if (sum == target) return new int[]{left, right};
    else if (sum &amp;lt; target) left++;
    else right--;
}

return new int[]{-1, -1};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Idea:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If sum is small → move left&lt;/li&gt;
&lt;li&gt;If sum is large → move right&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example 2: Remove Duplicates&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;public static int removeDuplicates(int[] arr) {&lt;br&gt;
    if (arr.length == 0) return 0;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int writeIndex = 1;

for (int readIndex = 1; readIndex &amp;lt; arr.length; readIndex++) {
    if (arr[readIndex] != arr[readIndex - 1]) {
        arr[writeIndex++] = arr[readIndex];
    }
}

return writeIndex;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
&lt;em&gt;Idea:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One pointer reads&lt;/li&gt;
&lt;li&gt;One pointer writes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example 3: Container With Most Water&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;public static int maxArea(int[] height) {&lt;br&gt;
    int left = 0, right = height.length - 1, max = 0;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (left &amp;lt; right) {
    max = Math.max(max,
        (right - left) * Math.min(height[left], height[right])
    );

    if (height[left] &amp;lt; height[right]) left++;
    else right--;
}

return max;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Idea:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Move pointer with smaller height&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Real Insight&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Two pointers eliminate unnecessary comparisons&lt;/p&gt;

&lt;p&gt;Instead of checking all pairs,&lt;br&gt;
you move intelligently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Insights&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Works best on sorted arrays&lt;/li&gt;
&lt;li&gt;Can be used for in-place operations&lt;/li&gt;
&lt;li&gt;Reduces O(n²) → O(n)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For More: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/two-pointer-technique" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/two-pointer-technique&lt;/a&gt;&lt;/p&gt;

</description>
      <category>database</category>
      <category>coding</category>
      <category>programming</category>
      <category>ai</category>
    </item>
    <item>
      <title>Sliding Window in Java: The Trick That Replaces Nested Loops</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Tue, 28 Apr 2026 05:40:58 +0000</pubDate>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e/sliding-window-in-java-the-trick-that-replaces-nested-loops-cf7</link>
      <guid>https://forem.com/quipoin_a9cb84280f6225b1e/sliding-window-in-java-the-trick-that-replaces-nested-loops-cf7</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvntlm993uxz3pu0wgdrz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvntlm993uxz3pu0wgdrz.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Many beginners write nested loops for subarray problems.&lt;/p&gt;

&lt;p&gt;That leads to O(n²) time complexity.&lt;/p&gt;

&lt;p&gt;But what if you could solve the same problem in O(n)?&lt;/p&gt;

&lt;p&gt;That’s where Sliding Window comes in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Sliding Window?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine a window covering part of the array.&lt;/p&gt;

&lt;p&gt;Instead of recalculating everything:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You remove one element&lt;/li&gt;
&lt;li&gt;You add one element&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Reuse previous computation&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fixed-Size Sliding Window&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Problem:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Find maximum sum of subarray of size k&lt;/p&gt;

&lt;p&gt;public static int maxSumFixedWindow(int[] arr, int k) {&lt;br&gt;
    int windowSum = 0;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (int i = 0; i &amp;lt; k; i++) windowSum += arr[i];

int maxSum = windowSum;

for (int i = k; i &amp;lt; arr.length; i++) {
    windowSum = windowSum - arr[i - k] + arr[i];
    maxSum = Math.max(maxSum, windowSum);
}

return maxSum;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Complexity:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time → O(n)&lt;/li&gt;
&lt;li&gt;Space → O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Fixed-Size Sliding Window&lt;br&gt;
💡 Problem:&lt;/p&gt;

&lt;p&gt;Find maximum sum of subarray of size k&lt;/p&gt;

&lt;p&gt;public static int maxSumFixedWindow(int[] arr, int k) {&lt;br&gt;
    int windowSum = 0;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (int i = 0; i &amp;lt; k; i++) windowSum += arr[i];

int maxSum = windowSum;

for (int i = k; i &amp;lt; arr.length; i++) {
    windowSum = windowSum - arr[i - k] + arr[i];
    maxSum = Math.max(maxSum, windowSum);
}

return maxSum;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
⏱️ Complexity:&lt;br&gt;
Time → O(n)&lt;br&gt;
Space → O(1)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Variable-Size Sliding Window&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Problem:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Find longest subarray with sum ≤ target&lt;/p&gt;

&lt;p&gt;public static int longestSubarraySumAtMost(int[] arr, int target) {&lt;br&gt;
    int left = 0, sum = 0, maxLen = 0;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (int right = 0; right &amp;lt; arr.length; right++) {
    sum += arr[right];

    while (sum &amp;gt; target) {
        sum -= arr[left];
        left++;
    }

    maxLen = Math.max(maxLen, right - left + 1);
}

return maxLen;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Complexity:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time → O(n)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Real Insight&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 Sliding window avoids recomputation&lt;/p&gt;

&lt;p&gt;Instead of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recalculating sum every time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adjust window dynamically&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Insights&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fixed window → size stays constant&lt;/li&gt;
&lt;li&gt;Variable window → expand &amp;amp; shrink&lt;/li&gt;
&lt;li&gt;Removes need for nested loops&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For More: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/sliding-window-basics" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/sliding-window-basics&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>code</category>
      <category>datastructures</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Stop Recomputing Sums: Learn Prefix Sum Technique</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Sun, 26 Apr 2026 11:34:52 +0000</pubDate>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e/stop-recomputing-sums-learn-prefix-sum-technique-21db</link>
      <guid>https://forem.com/quipoin_a9cb84280f6225b1e/stop-recomputing-sums-learn-prefix-sum-technique-21db</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F65s36pupagkhf3r5kl2b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F65s36pupagkhf3r5kl2b.png" alt=" " width="800" height="447"&gt;&lt;/a&gt;&lt;br&gt;
Imagine being asked multiple times:&lt;/p&gt;

&lt;p&gt;“What’s the sum from index L to R?”&lt;/p&gt;

&lt;p&gt;If you loop every time, your solution becomes slow.&lt;/p&gt;

&lt;p&gt;But what if you could answer every query in O(1)?&lt;/p&gt;

&lt;p&gt;That’s exactly what Prefix Sum does.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Prefix Sum?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Prefix sum stores cumulative sums.&lt;/p&gt;

&lt;p&gt;Each index stores sum from 0 to i&lt;/p&gt;

&lt;p&gt;int[] arr = {3, 1, 4, 2};&lt;br&gt;
int[] prefix = new int[arr.length];&lt;/p&gt;

&lt;p&gt;prefix[0] = arr[0];&lt;br&gt;
for (int i = 1; i &amp;lt; arr.length; i++) {&lt;br&gt;
    prefix[i] = prefix[i-1] + arr[i];&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Result:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;prefix = [3, 4, 8, 10]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Prefix Sum is Powerful&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Without prefix sum:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each query → O(n)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With prefix sum:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preprocessing → O(n)&lt;/li&gt;
&lt;li&gt;Each query → O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Range Sum Formula&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Use this:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;S(L,R)=prefix[R]−prefix[L−1]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Special case:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If L = 0 → just prefix[R]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;public static int rangeSum(int[] prefix, int L, int R) {&lt;br&gt;
    if (L == 0) return prefix[R];&lt;br&gt;
    return prefix[R] - prefix[L-1];&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Real Insight&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Do work once → reuse many times&lt;/p&gt;

&lt;p&gt;Instead of solving each query separately,&lt;br&gt;
you precompute smartly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Applications&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Range sum queries&lt;/li&gt;
&lt;li&gt;Subarray sum problems&lt;/li&gt;
&lt;li&gt;Equilibrium index&lt;/li&gt;
&lt;li&gt;2D prefix sum (matrix problems)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For More: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/prefix-sum-technique" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/prefix-sum-technique&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>coding</category>
      <category>programming</category>
      <category>cleancoding</category>
    </item>
    <item>
      <title>Multi-Dimensional Arrays Made Simple (With Java Examples)</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Sat, 25 Apr 2026 05:10:40 +0000</pubDate>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e/multi-dimensional-arrays-made-simple-with-java-examples-2j34</link>
      <guid>https://forem.com/quipoin_a9cb84280f6225b1e/multi-dimensional-arrays-made-simple-with-java-examples-2j34</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnsg2v9y08czo24u6vrus.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnsg2v9y08czo24u6vrus.jpg" alt=" " width="800" height="537"&gt;&lt;/a&gt;&lt;br&gt;
At some point, 1D arrays are not enough.&lt;/p&gt;

&lt;p&gt;What if you need to represent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A chess board&lt;/li&gt;
&lt;li&gt;A game grid&lt;/li&gt;
&lt;li&gt;A matrix&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s where multi-dimensional arrays come in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a 2D Array?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A 2D array is simply an array of arrays.&lt;/p&gt;

&lt;p&gt;Think of it like a table:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rows&lt;/li&gt;
&lt;li&gt;Columns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Declaration &amp;amp; Initialization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;// Declaration&lt;br&gt;
int[][] matrix = new int[3][4];&lt;/p&gt;

&lt;p&gt;// Initialization&lt;br&gt;
int[][] grid = {&lt;br&gt;
    {1, 2, 3},&lt;br&gt;
    {4, 5, 6},&lt;br&gt;
    {7, 8, 9}&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accessing Elements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;int element = grid[1][2]; // 6&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First index = row&lt;/li&gt;
&lt;li&gt;Second index = column&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Traversing a 2D Array&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;for (int i = 0; i &amp;lt; matrix.length; i++) {&lt;br&gt;
    for (int j = 0; j &amp;lt; matrix[i].length; j++) {&lt;br&gt;
        System.out.print(matrix[i][j] + " ");&lt;br&gt;
    }&lt;br&gt;
    System.out.println();&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Time Complexity: O(n × m)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visit each row and column&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Jagged Arrays&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unlike normal 2D arrays, rows can have different lengths.&lt;/p&gt;

&lt;p&gt;int[][] jagged = new int[3][];&lt;br&gt;
jagged[0] = new int[2];&lt;br&gt;
jagged[1] = new int[3];&lt;br&gt;
jagged[2] = new int[1];&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Useful when data is not uniform&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Real Insight&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;2D arrays = array of arrays&lt;/li&gt;
&lt;li&gt;Memory is not always perfectly rectangular&lt;/li&gt;
&lt;li&gt;Jagged arrays give flexibility&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Insights&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access → arr[row][col]&lt;/li&gt;
&lt;li&gt;Traversal → nested loops&lt;/li&gt;
&lt;li&gt;Jagged arrays → flexible rows&lt;/li&gt;
&lt;li&gt;Used in grids, DP, matrices&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For More: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/multi-dimensional-arrays" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/multi-dimensional-arrays&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>ai</category>
      <category>machinelearning</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Reverse, Rotate, Merge: The Patterns That Unlock DSA</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Sat, 25 Apr 2026 05:02:56 +0000</pubDate>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e/reverse-rotate-merge-the-patterns-that-unlock-dsa-dj8</link>
      <guid>https://forem.com/quipoin_a9cb84280f6225b1e/reverse-rotate-merge-the-patterns-that-unlock-dsa-dj8</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzqk9cb797capb8c191u5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzqk9cb797capb8c191u5.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
Most beginners try to memorize DSA problems.&lt;/p&gt;

&lt;p&gt;But interviews don’t test memory — they test patterns.&lt;/p&gt;

&lt;p&gt;If you master just these 3 array problems, you’ll unlock a huge part of DSA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Reverse an Array&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Idea:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Swap elements from both ends until you reach the middle.&lt;/p&gt;

&lt;p&gt;public static void reverse(int[] arr) {&lt;br&gt;
    int left = 0, right = arr.length - 1;&lt;br&gt;
    while (left &amp;lt; right) {&lt;br&gt;
        int temp = arr[left];&lt;br&gt;
        arr[left] = arr[right];&lt;br&gt;
        arr[right] = temp;&lt;br&gt;
        left++; right--;&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Complexity:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time → O(n)&lt;/li&gt;
&lt;li&gt;Space → O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Rotate Array by k Positions&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Idea:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Instead of shifting one-by-one, use 3 reversals.&lt;/p&gt;

&lt;p&gt;public static void rotate(int[] arr, int k) {&lt;br&gt;
    k = k % arr.length;&lt;br&gt;
    reverse(arr, 0, arr.length - 1);&lt;br&gt;
    reverse(arr, 0, k - 1);&lt;br&gt;
    reverse(arr, k, arr.length - 1);&lt;br&gt;
}&lt;br&gt;
private static void reverse(int[] arr, int start, int end) {&lt;br&gt;
    while (start &amp;lt; end) {&lt;br&gt;
        int temp = arr[start];&lt;br&gt;
        arr[start] = arr[end];&lt;br&gt;
        arr[end] = temp;&lt;br&gt;
        start++; end--;&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Complexity:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time → O(n)&lt;/li&gt;
&lt;li&gt;Space → O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Merge Two Sorted Arrays&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Idea:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Use two pointers and always pick the smaller element.&lt;/p&gt;

&lt;p&gt;public static int[] merge(int[] a, int[] b) {&lt;br&gt;
    int[] result = new int[a.length + b.length];&lt;br&gt;
    int i = 0, j = 0, k = 0;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (i &amp;lt; a.length &amp;amp;&amp;amp; j &amp;lt; b.length) {
    if (a[i] &amp;lt; b[j]) result[k++] = a[i++];
    else result[k++] = b[j++];
}

while (i &amp;lt; a.length) result[k++] = a[i++];
while (j &amp;lt; b.length) result[k++] = b[j++];

return result;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;Complexity:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time → O(n + m)&lt;/li&gt;
&lt;li&gt;Space → O(n + m)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Real Insight&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These problems are not random.&lt;/p&gt;

&lt;p&gt;They teach you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Two-pointer technique&lt;/li&gt;
&lt;li&gt;In-place modification&lt;/li&gt;
&lt;li&gt;Efficient traversal&lt;/li&gt;
&lt;li&gt;Pattern thinking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Insights&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reverse → swapping technique&lt;/li&gt;
&lt;li&gt;Rotate → smart use of reverse&lt;/li&gt;
&lt;li&gt;Merge → two pointers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These patterns repeat in advanced problems&lt;/p&gt;

&lt;p&gt;For More: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/array-problems" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/array-problems&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>java</category>
    </item>
    <item>
      <title>Reverse, Rotate, Merge: The Patterns That Unlock DSA</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Fri, 24 Apr 2026 11:18:42 +0000</pubDate>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e/reverse-rotate-merge-the-patterns-that-unlock-dsa-4f50</link>
      <guid>https://forem.com/quipoin_a9cb84280f6225b1e/reverse-rotate-merge-the-patterns-that-unlock-dsa-4f50</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzqk9cb797capb8c191u5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzqk9cb797capb8c191u5.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
Most beginners try to memorize DSA problems.&lt;/p&gt;

&lt;p&gt;But interviews don’t test memory — they test patterns.&lt;/p&gt;

&lt;p&gt;If you master just these 3 array problems, you’ll unlock a huge part of DSA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Reverse an Array&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Idea:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Swap elements from both ends until you reach the middle.&lt;/p&gt;

&lt;p&gt;public static void reverse(int[] arr) {&lt;br&gt;
    int left = 0, right = arr.length - 1;&lt;br&gt;
    while (left &amp;lt; right) {&lt;br&gt;
        int temp = arr[left];&lt;br&gt;
        arr[left] = arr[right];&lt;br&gt;
        arr[right] = temp;&lt;br&gt;
        left++; right--;&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Complexity:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time → O(n)&lt;/li&gt;
&lt;li&gt;Space → O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Rotate Array by k Positions&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Idea:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Instead of shifting one-by-one, use 3 reversals.&lt;/p&gt;

&lt;p&gt;public static void rotate(int[] arr, int k) {&lt;br&gt;
    k = k % arr.length;&lt;br&gt;
    reverse(arr, 0, arr.length - 1);&lt;br&gt;
    reverse(arr, 0, k - 1);&lt;br&gt;
    reverse(arr, k, arr.length - 1);&lt;br&gt;
}&lt;br&gt;
private static void reverse(int[] arr, int start, int end) {&lt;br&gt;
    while (start &amp;lt; end) {&lt;br&gt;
        int temp = arr[start];&lt;br&gt;
        arr[start] = arr[end];&lt;br&gt;
        arr[end] = temp;&lt;br&gt;
        start++; end--;&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Complexity:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time → O(n)&lt;/li&gt;
&lt;li&gt;Space → O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Merge Two Sorted Arrays&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Idea:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Use two pointers and always pick the smaller element.&lt;/p&gt;

&lt;p&gt;public static int[] merge(int[] a, int[] b) {&lt;br&gt;
    int[] result = new int[a.length + b.length];&lt;br&gt;
    int i = 0, j = 0, k = 0;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (i &amp;lt; a.length &amp;amp;&amp;amp; j &amp;lt; b.length) {
    if (a[i] &amp;lt; b[j]) result[k++] = a[i++];
    else result[k++] = b[j++];
}

while (i &amp;lt; a.length) result[k++] = a[i++];
while (j &amp;lt; b.length) result[k++] = b[j++];

return result;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;Complexity:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time → O(n + m)&lt;/li&gt;
&lt;li&gt;Space → O(n + m)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Real Insight&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These problems are not random.&lt;/p&gt;

&lt;p&gt;They teach you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Two-pointer technique&lt;/li&gt;
&lt;li&gt;In-place modification&lt;/li&gt;
&lt;li&gt;Efficient traversal&lt;/li&gt;
&lt;li&gt;Pattern thinking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Insights&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reverse → swapping technique&lt;/li&gt;
&lt;li&gt;Rotate → smart use of reverse&lt;/li&gt;
&lt;li&gt;Merge → two pointers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These patterns repeat in advanced problems&lt;/p&gt;

&lt;p&gt;For More: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/array-problems" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/array-problems&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>java</category>
      <category>codinginterview</category>
      <category>learndsa</category>
    </item>
    <item>
      <title>Traversal, Insertion, Deletion The Truth About Array Performance</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Mon, 20 Apr 2026 10:41:24 +0000</pubDate>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e/traversal-insertion-deletion-the-truth-about-array-performance-1gfl</link>
      <guid>https://forem.com/quipoin_a9cb84280f6225b1e/traversal-insertion-deletion-the-truth-about-array-performance-1gfl</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxpnhk27n3qk1zypyruri.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxpnhk27n3qk1zypyruri.png" alt=" " width="800" height="544"&gt;&lt;/a&gt;&lt;br&gt;
Arrays look simple… but the way operations behave on them can make or break your performance.&lt;/p&gt;

&lt;p&gt;Why is accessing an element instant, but inserting in the middle slow?&lt;/p&gt;

&lt;p&gt;Let’s break it down in the simplest way possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Traversal (Visiting Elements)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Traversal means visiting each element one by one.&lt;/p&gt;

&lt;p&gt;for (int i = 0; i &amp;lt; arr.length; i++) {&lt;br&gt;
    System.out.println(arr[i]);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;// Enhanced loop&lt;br&gt;
for (int num : arr) {&lt;br&gt;
    System.out.println(num);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time Complexity: O(n)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You must visit every element&lt;/li&gt;
&lt;li&gt;No shortcut possible&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Insertion&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Case 1: Insert at End&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If space is available → O(1)&lt;/li&gt;
&lt;li&gt;Just place the element&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Case 2: Insert at Middle&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;public static void insert(int[] arr, int pos, int value) {&lt;br&gt;
    for (int i = arr.length - 1; i &amp;gt; pos; i--) {&lt;br&gt;
        arr[i] = arr[i - 1];&lt;br&gt;
    }&lt;br&gt;
    arr[pos] = value;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time Complexity: O(n)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Why slow?&lt;/em&gt;&lt;br&gt;
Because elements need to shift right&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Deletion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Case 1: Delete from End&lt;/em&gt;&lt;br&gt;
Simply remove → O(1)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Case 2: Delete from Middle&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;public static void delete(int[] arr, int pos) {&lt;br&gt;
    for (int i = pos; i &amp;lt; arr.length - 1; i++) {&lt;br&gt;
        arr[i] = arr[i + 1];&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time Complexity: O(n)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Again, shifting required (left side)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Real Insight&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arrays are fast for reading&lt;/li&gt;
&lt;li&gt;But slow for modifying in the middle&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because of one reason:&lt;/p&gt;

&lt;p&gt;Shifting elements = extra work = O(n)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Insights&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Traversal → O(n)&lt;/li&gt;
&lt;li&gt;Insert at end → O(1)&lt;/li&gt;
&lt;li&gt;Insert in middle → O(n)&lt;/li&gt;
&lt;li&gt;Delete from end → O(1)&lt;/li&gt;
&lt;li&gt;Delete from middle → O(n)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For More: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/array-operations" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/array-operations&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>java</category>
      <category>coding</category>
      <category>timecomplexity</category>
    </item>
    <item>
      <title>Why Arrays Are So Fast (And Why It Matters in DSA)</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Sun, 19 Apr 2026 07:09:38 +0000</pubDate>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e/why-arrays-are-so-fast-and-why-it-matters-in-dsa-n0b</link>
      <guid>https://forem.com/quipoin_a9cb84280f6225b1e/why-arrays-are-so-fast-and-why-it-matters-in-dsa-n0b</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh856yxwgqesgt7cpiatm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh856yxwgqesgt7cpiatm.png" alt=" " width="800" height="474"&gt;&lt;/a&gt;&lt;br&gt;
Before you jump into advanced Data Structures like stacks, queues, or hash tables, there’s one concept you must fully understand Arrays.&lt;/p&gt;

&lt;p&gt;If arrays are unclear, everything else in DSA will feel complicated.&lt;/p&gt;

&lt;p&gt;Let’s fix that in the simplest way possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is an Array?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Think of an array like a row of lockers.&lt;/p&gt;

&lt;p&gt;Each locker:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Has a fixed position (index)&lt;/li&gt;
&lt;li&gt;Stores one value&lt;/li&gt;
&lt;li&gt;Can be accessed instantly if you know the index&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Java, an array stores elements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Of the same type&lt;/li&gt;
&lt;li&gt;In continuous memory locations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Arrays Are Fast (O(1) Access)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Arrays allow direct access using index.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;int[] arr = {2, 3, 5, 7};&lt;br&gt;
System.out.println(arr[2]); // 5&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No searching required&lt;/li&gt;
&lt;li&gt;Direct memory access&lt;/li&gt;
&lt;li&gt;That’s why time complexity is O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Properties of Arrays&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fixed Size → cannot change after creation&lt;/li&gt;
&lt;li&gt;Contiguous Memory → stored in a continuous block&lt;/li&gt;
&lt;li&gt;Index-Based Access → starts from 0&lt;/li&gt;
&lt;li&gt;Homogeneous → same data type&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Array Declaration in Java&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;// Declaration&lt;br&gt;
int[] numbers;&lt;/p&gt;

&lt;p&gt;// Allocation&lt;br&gt;
numbers = new int[5];&lt;/p&gt;

&lt;p&gt;// Initialization&lt;br&gt;
int[] primes = {2, 3, 5, 7};&lt;br&gt;
String[] names = new String[]{"Alice", "Bob"};&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Accessing Elements&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;int first = primes[0];   // 2&lt;br&gt;
primes[2] = 11;          // update value&lt;br&gt;
int length = primes.length;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Insights&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arrays are objects in Java&lt;/li&gt;
&lt;li&gt;They come with a .length property&lt;/li&gt;
&lt;li&gt;Default values:&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;int → 0&lt;/li&gt;
&lt;li&gt;boolean → false&lt;/li&gt;
&lt;li&gt;object → null&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For More: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/array-introduction" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/array-introduction&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>java</category>
      <category>coding</category>
      <category>developer</category>
    </item>
    <item>
      <title>How to Solve Complex Problems Step-by-Step (Backtracking Explained)</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Sat, 18 Apr 2026 05:26:36 +0000</pubDate>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e/how-to-solve-complex-problems-step-by-step-backtracking-explained-3hbb</link>
      <guid>https://forem.com/quipoin_a9cb84280f6225b1e/how-to-solve-complex-problems-step-by-step-backtracking-explained-3hbb</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9o21l62vodqpvhq4mer0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9o21l62vodqpvhq4mer0.png" alt=" " width="800" height="602"&gt;&lt;/a&gt;&lt;br&gt;
Ever faced a problem where you need to try all possible solutions… but don’t know how?&lt;/p&gt;

&lt;p&gt;That’s where Backtracking comes in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;What is Backtracking?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Backtracking is a technique where you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Try a solution&lt;/li&gt;
&lt;li&gt;If it fails → go back&lt;/li&gt;
&lt;li&gt;Try another path&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s like solving a maze:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Take a path&lt;/li&gt;
&lt;li&gt;Hit a dead end&lt;/li&gt;
&lt;li&gt;Go back and try another route&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Where is Backtracking Used?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;N-Queens problem&lt;/li&gt;
&lt;li&gt;Sudoku solver&lt;/li&gt;
&lt;li&gt;Generating subsets&lt;/li&gt;
&lt;li&gt;Permutations &amp;amp; combinations&lt;/li&gt;
&lt;li&gt;Rat in a maze&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;General Backtracking Template&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;void backtrack(parameters) {&lt;br&gt;
    if (solution found) {&lt;br&gt;
        process solution;&lt;br&gt;
        return;&lt;br&gt;
    }&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (int candidate : candidates) {
    if (isValid(candidate)) {
        makeChoice(candidate);

        backtrack(updatedParameters);

        undoChoice(candidate); // backtrack
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Example: Generate All Subsets&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;void subsets(int[] nums, int index, List current, List&amp;gt; result) {&lt;br&gt;
    result.add(new ArrayList&amp;lt;&amp;gt;(current));&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (int i = index; i &amp;lt; nums.length; i++) {
    current.add(nums[i]);

    subsets(nums, i + 1, current, result);

    current.remove(current.size() - 1); // backtrack
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Key Idea&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Backtracking works in 3 steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Choose&lt;/li&gt;
&lt;li&gt;Explore&lt;/li&gt;
&lt;li&gt;Undo (Backtrack)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This ensures all possibilities are explored.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Important Note&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time complexity is often exponential &lt;/li&gt;
&lt;li&gt;But pruning (skipping invalid paths early) improves performance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For More: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/backtracking-basics" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/backtracking-basics&lt;/a&gt;&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>java</category>
      <category>recursion</category>
      <category>datastructures</category>
    </item>
    <item>
      <title>Recursion vs Iteration: Which One Should You Use?</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Sun, 12 Apr 2026 05:23:25 +0000</pubDate>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e/recursion-vs-iteration-which-one-should-you-use-3b11</link>
      <guid>https://forem.com/quipoin_a9cb84280f6225b1e/recursion-vs-iteration-which-one-should-you-use-3b11</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpdcpc7i9t7xtky6nlg8r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpdcpc7i9t7xtky6nlg8r.png" alt=" " width="800" height="716"&gt;&lt;/a&gt;&lt;br&gt;
Do you prefer clean code… or fast code?&lt;/p&gt;

&lt;p&gt;In programming, many problems can be solved in two ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recursion&lt;/li&gt;
&lt;li&gt;Iteration (loops)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both work… but they behave very differently.&lt;/p&gt;

&lt;p&gt;So the real question is:&lt;br&gt;
Which one should you use?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;What is Recursion?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Recursion is when a function calls itself to solve smaller parts of a problem.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Short and elegant code&lt;/li&gt;
&lt;li&gt;Matches mathematical definitions&lt;/li&gt;
&lt;li&gt;Perfect for trees, graphs, divide &amp;amp; conquer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uses extra memory (call stack)&lt;/li&gt;
&lt;li&gt;Can be slower&lt;/li&gt;
&lt;li&gt;Risk of stack overflow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;What is Iteration?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Iteration uses loops (for, while) to repeat steps until a condition is met.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster in most cases&lt;/li&gt;
&lt;li&gt;Uses constant memory&lt;/li&gt;
&lt;li&gt;No risk of stack overflow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code can be longer&lt;/li&gt;
&lt;li&gt;Harder to write for complex problems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Example: Fibonacci&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Recursive Approach (Slow)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;static int fibRecursive(int n) {&lt;br&gt;
    if (n &amp;lt;= 1) return n;&lt;br&gt;
    return fibRecursive(n-1) + fibRecursive(n-2);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Time Complexity: O(2ⁿ)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Iterative Approach (Efficient)&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;static int fibIterative(int n) {&lt;br&gt;
    if (n &amp;lt;= 1) return n;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int prev2 = 0, prev1 = 1, current = 0;

for (int i = 2; i &amp;lt;= n; i++) {
    current = prev1 + prev2;
    prev2 = prev1;
    prev1 = current;
}

return current;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;Time Complexity: O(n)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;When Should You Use What?&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Use Recursion when:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Problem has recursive structure&lt;/li&gt;
&lt;li&gt;Working with trees or graphs&lt;/li&gt;
&lt;li&gt;Using divide &amp;amp; conquer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Use Iteration when:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Performance matters&lt;/li&gt;
&lt;li&gt;Input size is large&lt;/li&gt;
&lt;li&gt;You want to avoid memory overhead&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are learning DSA step-by-step, check more guides here:&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
      &lt;div class="c-embed__body flex items-center justify-between"&gt;
        &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/recursion-vs-iteration" rel="noopener noreferrer" class="c-link fw-bold flex items-center"&gt;
          &lt;span class="mr-2"&gt;quipoin.com&lt;/span&gt;
          

        &lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>programming</category>
      <category>java</category>
      <category>algorithms</category>
      <category>datastructures</category>
    </item>
    <item>
      <title>Why Recursion Confuses Most Beginners</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Sat, 11 Apr 2026 08:08:12 +0000</pubDate>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e/why-recursion-confuses-most-beginners-1mno</link>
      <guid>https://forem.com/quipoin_a9cb84280f6225b1e/why-recursion-confuses-most-beginners-1mno</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdhbs7mb6uyktye4kl6ts.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdhbs7mb6uyktye4kl6ts.png" alt=" " width="800" height="538"&gt;&lt;/a&gt;&lt;br&gt;
Recursion is one of the most powerful…&lt;br&gt;
and confusing concepts in programming 😳&lt;/p&gt;

&lt;p&gt;Let’s break it down in the simplest way possible.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Real-Life Example&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Think of a Russian doll:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You open one → another inside&lt;/li&gt;
&lt;li&gt;Open again → another inside&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Same pattern repeats&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is exactly how recursion works.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;What is Recursion?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Recursion is a technique where a function calls itself to solve a smaller version of the same problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Two Important Parts&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Base Case&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stops recursion&lt;/li&gt;
&lt;li&gt;Prevents infinite loop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Recursive Case&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Function calls itself&lt;/li&gt;
&lt;li&gt;Reduces problem size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Example: Factorial&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;public static int factorial(int n) {&lt;br&gt;
    // base case&lt;br&gt;
    if (n &amp;lt;= 1) return 1;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// recursive case
return n * factorial(n - 1);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;How It Works&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;factorial(3)&lt;br&gt;
= 3 * factorial(2)&lt;br&gt;
= 3 * 2 * factorial(1)&lt;br&gt;
= 3 * 2 * 1&lt;br&gt;
= 6&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Where Recursion is Used&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Trees&lt;/li&gt;
&lt;li&gt;Graphs&lt;/li&gt;
&lt;li&gt;Divide &amp;amp; Conquer&lt;/li&gt;
&lt;li&gt;Fibonacci&lt;/li&gt;
&lt;li&gt;Backtracking problems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For More: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/recursion-introduction" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/recursion-introduction&lt;/a&gt;&lt;/p&gt;

</description>
      <category>recursion</category>
      <category>dsa</category>
      <category>algorithms</category>
      <category>datastructures</category>
    </item>
    <item>
      <title>Same Algorithm, Different Performance? | Best, Average, Worst Case Explained</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Mon, 06 Apr 2026 06:29:10 +0000</pubDate>
      <link>https://forem.com/quipoin_a9cb84280f6225b1e/same-algorithm-different-performance-best-average-worst-case-explained-3na6</link>
      <guid>https://forem.com/quipoin_a9cb84280f6225b1e/same-algorithm-different-performance-best-average-worst-case-explained-3na6</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzy4i2e6ac4yjkc168zn0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzy4i2e6ac4yjkc168zn0.png" alt=" " width="800" height="415"&gt;&lt;/a&gt;&lt;br&gt;
You wrote an algorithm… and it works perfectly&lt;/p&gt;

&lt;p&gt;But sometimes it runs fast…&lt;br&gt;
and sometimes it becomes slow&lt;/p&gt;

&lt;p&gt;Why does this happen?&lt;/p&gt;

&lt;p&gt;Because algorithm performance depends on the input case&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Three Types of Cases&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Best Case&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fastest possible scenario&lt;/li&gt;
&lt;li&gt;Example: target found at first index&lt;/li&gt;
&lt;li&gt;Time: O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Average Case&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Typical scenario across all inputs&lt;/li&gt;
&lt;li&gt;Expected performance&lt;/li&gt;
&lt;li&gt;Time: O(n)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Worst Case&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Slowest possible scenario&lt;/li&gt;
&lt;li&gt;Example: element not found or at last index&lt;/li&gt;
&lt;li&gt;Time: O(n)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example: Linear Search&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;int linearSearch(int[] arr, int target) {&lt;br&gt;
    for (int i = 0; i &amp;lt; arr.length; i++) {&lt;br&gt;
        if (arr[i] == target) return i;&lt;br&gt;
    }&lt;br&gt;
    return -1;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Case Analysis&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Best Case → element at index 0 → O(1)&lt;/li&gt;
&lt;li&gt;Worst Case → element not found → O(n)&lt;/li&gt;
&lt;li&gt;Average Case → ~n/2 comparisons → O(n)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Do We Focus on Worst Case?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because it gives a guarantee:&lt;/p&gt;

&lt;p&gt;“Algorithm will NEVER take more than this time”&lt;/p&gt;

&lt;p&gt;This is critical for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Large-scale systems&lt;/li&gt;
&lt;li&gt;Real-time applications&lt;/li&gt;
&lt;li&gt;Performance-sensitive code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For More: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/best-average-worst-case" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/best-average-worst-case&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>algorithms</category>
      <category>average</category>
      <category>coding</category>
    </item>
  </channel>
</rss>
