<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Quipoin</title>
    <description>The latest articles on DEV Community by Quipoin (@quipoin_a9cb84280f6225b1e).</description>
    <link>https://dev.to/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>DEV Community: Quipoin</title>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/quipoin_a9cb84280f6225b1e"/>
    <language>en</language>
    <item>
      <title>Why Linked Lists Are Different from Arrays</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Sun, 24 May 2026 04:08:00 +0000</pubDate>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e/why-linked-lists-are-different-from-arrays-2dj6</link>
      <guid>https://dev.to/quipoin_a9cb84280f6225b1e/why-linked-lists-are-different-from-arrays-2dj6</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%2F1dkes7n1cyizquss1cmp.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%2F1dkes7n1cyizquss1cmp.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Arrays are great for fast access…&lt;/p&gt;

&lt;p&gt;But inserting or deleting elements can be expensive.&lt;/p&gt;

&lt;p&gt;That’s where Linked Lists become powerful.&lt;/p&gt;

&lt;p&gt;A Singly Linked List connects nodes like a chain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;each node points only to the next node.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1. Structure of a Singly Linked List&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Visual representation:&lt;/p&gt;

&lt;p&gt;[10] → [20] → [30] → null&lt;/p&gt;

&lt;p&gt;Each node contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;data&lt;/li&gt;
&lt;li&gt;reference to next node&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Insert at Head&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Idea&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;New node becomes the first node.&lt;/p&gt;

&lt;p&gt;public void insertAtHead(int data) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Node newNode = new Node(data);

newNode.next = head;

head = newNode;
&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;p&gt;O(1) insertion at head&lt;/p&gt;

&lt;p&gt;Because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;no traversal needed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Insert at End&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Idea&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Traverse until last node.&lt;/p&gt;

&lt;p&gt;public void insertAtEnd(int data) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Node newNode = new Node(data);

if (head == null) {
    head = newNode;
    return;
}

Node temp = head;

while (temp.next != null) {
    temp = temp.next;
}

temp.next = newNode;
&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;p&gt;O(n) insertion at end&lt;/p&gt;

&lt;p&gt;Because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;traversal is required.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Delete a Node&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Idea&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Find previous node,&lt;br&gt;
then bypass target node.&lt;/p&gt;

&lt;p&gt;public void delete(int key) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (head == null)
    return;

if (head.data == key) {
    head = head.next;
    return;
}

Node temp = head;

while (temp.next != null &amp;amp;&amp;amp;
       temp.next.data != key) {

    temp = temp.next;
}

if (temp.next != null) {
    temp.next = temp.next.next;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
&lt;strong&gt;5. Traversal&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Idea&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Move node by node until null.&lt;/p&gt;

&lt;p&gt;public void printList() {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Node temp = head;

while (temp != null) {

    System.out.print(temp.data + " -&amp;gt; ");

    temp = temp.next;
}

System.out.println("null");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;Linked Lists trade:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;random access&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;flexible insertions/deletions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s their main strength.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nodes form a one-way chain&lt;/li&gt;
&lt;li&gt;Head stores first node&lt;/li&gt;
&lt;li&gt;Insert at head → O(1)&lt;/li&gt;
&lt;li&gt;Traversal → O(n)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Singly Linked Lists are one of the most important DSA foundations.&lt;/p&gt;

&lt;p&gt;Understanding them deeply makes advanced structures much easier&lt;/p&gt;

&lt;p&gt;Explore More: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/singly-linked-list" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/singly-linked-list&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>algorithms</category>
      <category>career</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The Data Structure That Powers Stacks &amp; Queues</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Sat, 23 May 2026 04:21:51 +0000</pubDate>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e/the-data-structure-that-powers-stacks-queues-1235</link>
      <guid>https://dev.to/quipoin_a9cb84280f6225b1e/the-data-structure-that-powers-stacks-queues-1235</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%2Fdfw9z0ey67iv4r3ql4w8.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%2Fdfw9z0ey67iv4r3ql4w8.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Imagine a treasure hunt…&lt;/p&gt;

&lt;p&gt;Each clue tells you where the next clue is.&lt;/p&gt;

&lt;p&gt;That’s exactly how a Linked List works.&lt;/p&gt;

&lt;p&gt;Instead of storing elements side-by-side like arrays,&lt;br&gt;
each node stores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;data&lt;/li&gt;
&lt;li&gt;a reference to the next node&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1. What is a Linked List?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A Linked List is a linear data structure made of nodes.&lt;/p&gt;

&lt;p&gt;Each node contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;actual data&lt;/li&gt;
&lt;li&gt;link to next node&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Node Structure in Java&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;public class Node {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int data;
Node next;

public Node(int data) {

    this.data = data;
    this.next = null;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

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

&lt;p&gt;Visual representation:&lt;/p&gt;

&lt;p&gt;[10] → [20] → [30] → null&lt;/p&gt;

&lt;p&gt;Each node knows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;where the next node exists.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;2. Why Use Linked Lists?&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Unlike arrays:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;linked lists do NOT require contiguous memory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This gives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dynamic size&lt;/li&gt;
&lt;li&gt;flexible insertion/deletion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Dynamic Size&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Linked list can grow/shrink easily.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fast Insert/Delete&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If reference is available:&lt;/p&gt;

&lt;p&gt;O(1) insertion/deletion&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Better Memory Usage&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;No fixed-size allocation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Drawbacks of Linked Lists&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Slow Access&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To reach an element:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;traverse node by node.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;O(n) access&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Extra Memory&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Every node stores an additional pointer.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Not Cache Friendly&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Nodes are scattered in memory.&lt;/p&gt;

&lt;p&gt;Linked Lists trade:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fast access&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;flexible insertion &amp;amp; deletion.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s why they are useful in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;stacks&lt;/li&gt;
&lt;li&gt;queues&lt;/li&gt;
&lt;li&gt;graph structures&lt;/li&gt;
&lt;li&gt;hash tables&lt;/li&gt;
&lt;li&gt;Linked list = chain of nodes&lt;/li&gt;
&lt;li&gt;Nodes store data + next reference&lt;/li&gt;
&lt;li&gt;Dynamic structure&lt;/li&gt;
&lt;li&gt;Slower random access&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Linked Lists may seem simple…&lt;/p&gt;

&lt;p&gt;But they form the foundation of many advanced data structures&lt;/p&gt;

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

</description>
      <category>java</category>
      <category>algorithms</category>
      <category>beginners</category>
      <category>career</category>
    </item>
    <item>
      <title>Sliding Window on Strings Explained Simply in Java</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Wed, 20 May 2026 12:19:04 +0000</pubDate>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e/sliding-window-on-strings-explained-simply-in-java-18n</link>
      <guid>https://dev.to/quipoin_a9cb84280f6225b1e/sliding-window-on-strings-explained-simply-in-java-18n</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%2Fj632oitssss4xulooeld.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%2Fj632oitssss4xulooeld.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Many string problems look complicated because they involve:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;substrings&lt;/li&gt;
&lt;li&gt;repeated characters&lt;/li&gt;
&lt;li&gt;dynamic conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Beginners often use nested loops…&lt;/p&gt;

&lt;p&gt;But sliding window reduces many of these problems from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;O(n²)
to:&lt;/li&gt;
&lt;li&gt;O(n)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1. Longest Substring Without Repeating Characters&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Problem&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Find the length of the longest substring with unique characters.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Efficient Sliding Window Solution&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;public static int lengthOfLongestSubstring(String s) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set&amp;lt;Character&amp;gt; set = new HashSet&amp;lt;&amp;gt;();

int left = 0, maxLen = 0;

for (int right = 0; right &amp;lt; s.length(); right++) {

    while (set.contains(s.charAt(right))) {

        set.remove(s.charAt(left));

        left++;
    }

    set.add(s.charAt(right));

    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;Core Idea&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Maintain a window:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;expand right pointer&lt;/li&gt;
&lt;li&gt;shrink left when duplicate appears&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This keeps the substring valid.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;2. Minimum Window Substring&lt;br&gt;
*&lt;/em&gt;&lt;em&gt;Problem&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Find the smallest substring containing all characters of a pattern.&lt;/p&gt;

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

&lt;p&gt;Text = "ADOBECODEBANC"&lt;br&gt;
Pattern = "ABC"&lt;/p&gt;

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

&lt;p&gt;"BANC"&lt;/p&gt;

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

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

&lt;ul&gt;
&lt;li&gt;character frequency counts&lt;/li&gt;
&lt;li&gt;dynamic window resizing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Expand until valid,&lt;br&gt;
then shrink to minimize window.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Longest Repeating Character Replacement&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Problem&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Given:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a string&lt;/li&gt;
&lt;li&gt;k replacements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Find the longest substring that can become all same characters.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Smart Observation&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Track:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;most frequent character inside window.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If:&lt;/p&gt;

&lt;p&gt;windowSize - maxFreq &amp;gt; k&lt;/p&gt;

&lt;p&gt;then shrink window.&lt;/p&gt;

&lt;p&gt;Sliding window works because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;we reuse previous computations instead of recalculating substrings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s the optimization.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sliding window avoids nested loops&lt;/li&gt;
&lt;li&gt;Expand → valid state&lt;/li&gt;
&lt;li&gt;Use two pointers&lt;/li&gt;
&lt;li&gt;Track characters using set/map&lt;/li&gt;
&lt;li&gt;Expand right pointer&lt;/li&gt;
&lt;li&gt;Shrink left when condition breaks&lt;/li&gt;
&lt;li&gt;Complexity → O(n)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sliding window is one of the most important interview patterns.&lt;/p&gt;

&lt;p&gt;Once you master it,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;many “hard” string problems become manageable&lt;/li&gt;
&lt;/ul&gt;

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

</description>
      <category>java</category>
      <category>algorithms</category>
      <category>career</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Anagram &amp; Palindrome Problems Explained Simply in Java</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Tue, 19 May 2026 05:27:21 +0000</pubDate>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e/anagram-palindrome-problems-explained-simply-in-java-14jo</link>
      <guid>https://dev.to/quipoin_a9cb84280f6225b1e/anagram-palindrome-problems-explained-simply-in-java-14jo</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%2F7ws4m3fwi2bnd1petfuq.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%2F7ws4m3fwi2bnd1petfuq.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
String interview questions often look tricky…&lt;/p&gt;

&lt;p&gt;But many of them are built on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;character counting&lt;/li&gt;
&lt;li&gt;frequency matching&lt;/li&gt;
&lt;li&gt;two-pointer logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Anagram and palindrome problems are perfect examples.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Check if Two Strings are Anagrams&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Two strings are anagrams if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;both contain the same characters&lt;/li&gt;
&lt;li&gt;with the same frequency.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;listen&lt;/li&gt;
&lt;li&gt;silent&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Efficient Approach&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Use a frequency array.&lt;/p&gt;

&lt;p&gt;public static boolean areAnagrams(String s1, String s2) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (s1.length() != s2.length())
    return false;

int[] freq = new int[26];

for (int i = 0; i &amp;lt; s1.length(); i++) {

    freq[s1.charAt(i) - 'a']++;
    freq[s2.charAt(i) - 'a']--;
}

for (int count : freq) {

    if (count != 0)
        return false;
}

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

&lt;/div&gt;

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

&lt;p&gt;&lt;em&gt;Why This Works&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If both strings contain the same letters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;all frequencies cancel out to zero.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Group Anagrams&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;["eat", "tea", "tan", "ate"]&lt;/p&gt;

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

&lt;p&gt;[["eat","tea","ate"], ["tan"]]&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Smart Trick&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Sort characters of each string.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;eat → aet&lt;/li&gt;
&lt;li&gt;tea → aet&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Same sorted form:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;same group.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;public static List&amp;gt; groupAnagrams(String[] strs) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Map&amp;lt;String, List&amp;lt;String&amp;gt;&amp;gt; map = new HashMap&amp;lt;&amp;gt;();

for (String s : strs) {

    char[] arr = s.toCharArray();

    Arrays.sort(arr);

    String key = new String(arr);

    map.computeIfAbsent(key,
        k -&amp;gt; new ArrayList&amp;lt;&amp;gt;()).add(s);
}

return new ArrayList&amp;lt;&amp;gt;(map.values());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;&lt;strong&gt;3. Palindrome Check&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Palindrome:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reads same forwards &amp;amp; backwards.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;madam&lt;/li&gt;
&lt;li&gt;racecar&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Two Pointer Technique&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Compare:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;left character&lt;/li&gt;
&lt;li&gt;right character&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Move inward until middle.&lt;/p&gt;

&lt;p&gt;Most string interview problems are about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;counting characters&lt;/li&gt;
&lt;li&gt;comparing efficiently&lt;/li&gt;
&lt;li&gt;reducing repeated work&lt;/li&gt;
&lt;li&gt;Anagrams → frequency matching&lt;/li&gt;
&lt;li&gt;Grouping → hashing + sorting&lt;/li&gt;
&lt;li&gt;Palindrome → two pointers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These problems may look basic…&lt;/p&gt;

&lt;p&gt;But the same logic appears in advanced interview questions too&lt;/p&gt;

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

</description>
      <category>java</category>
      <category>algorithms</category>
      <category>career</category>
      <category>beginer</category>
    </item>
    <item>
      <title>Pattern Matching in Java: Naive Search vs KMP Explained</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Mon, 18 May 2026 06:34:29 +0000</pubDate>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e/pattern-matching-in-java-naive-search-vs-kmp-explained-b2</link>
      <guid>https://dev.to/quipoin_a9cb84280f6225b1e/pattern-matching-in-java-naive-search-vs-kmp-explained-b2</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%2Fi8p2n0pm51j5p3o461xn.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%2Fi8p2n0pm51j5p3o461xn.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Ever wondered how:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;browsers search text&lt;/li&gt;
&lt;li&gt;editors find words&lt;/li&gt;
&lt;li&gt;search engines process patterns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It all starts with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pattern Matching.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is simple:&lt;br&gt;
Find a smaller string (pattern)&lt;br&gt;
inside a larger string (text).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Naive Pattern Matching&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The simplest approach:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check every possible starting position.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;public static int naiveSearch(String text, String pattern) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int n = text.length();
int m = pattern.length();

for (int i = 0; i &amp;lt;= n - m; i++) {

    int j;

    for (j = 0; j &amp;lt; m; j++) {

        if (text.charAt(i + j) != pattern.charAt(j))
            break;
    }

    if (j == m)
        return i;
}

return -1;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

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

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

&lt;p&gt;Text:&lt;/p&gt;

&lt;p&gt;ABABDABACDABABCABAB&lt;/p&gt;

&lt;p&gt;Pattern:&lt;/p&gt;

&lt;p&gt;ABABC&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start checking from every position.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If mismatch occurs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;shift pattern by one step.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Problem with Naive Approach&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Worst-case complexity:&lt;/p&gt;

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

&lt;p&gt;Because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;characters get rechecked multiple times.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. KMP Algorithm (Basic Idea)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;KMP improves performance using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LPS array (Longest Prefix Suffix)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of restarting from zero:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it uses previous match information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;KMP Complexity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;O(n+m)&lt;/p&gt;

&lt;p&gt;This is much faster for large strings.&lt;/p&gt;

&lt;p&gt;KMP is powerful because it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;remembers previous matches&lt;/li&gt;
&lt;li&gt;avoids unnecessary comparisons&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s the optimization.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pattern matching = substring search&lt;/li&gt;
&lt;li&gt;Naive approach is simple but slower&lt;/li&gt;
&lt;li&gt;KMP uses preprocessing for speed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vist Full Tutorials Here: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/pattern-matching-basics" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/pattern-matching-basics&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>algorithms</category>
      <category>career</category>
      <category>beginners</category>
    </item>
    <item>
      <title>StringBuilder vs StringBuffer in Java</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Sun, 17 May 2026 06:54:17 +0000</pubDate>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e/stringbuilder-vs-stringbuffer-in-java-51m2</link>
      <guid>https://dev.to/quipoin_a9cb84280f6225b1e/stringbuilder-vs-stringbuffer-in-java-51m2</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%2Fc0867csg9fqdgharbj0r.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%2Fc0867csg9fqdgharbj0r.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Many beginners write code like this:&lt;/p&gt;

&lt;p&gt;String s = "";&lt;/p&gt;

&lt;p&gt;for (int i = 0; i &amp;lt; 10000; i++) {&lt;br&gt;
    s += i;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Looks harmless…&lt;/p&gt;

&lt;p&gt;But internally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;thousands of new String objects are created&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s why Java provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;StringBuilder&lt;/li&gt;
&lt;li&gt;StringBuffer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Regular String Is Slow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Strings in Java are immutable.&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;p&gt;s += "Java";&lt;/p&gt;

&lt;p&gt;does NOT modify the existing string.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;a completely new object is created.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1. StringBuilder&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;StringBuilder is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mutable&lt;/li&gt;
&lt;li&gt;Fast&lt;/li&gt;
&lt;li&gt;Not thread-safe&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;StringBuilder sb = new StringBuilder();&lt;/p&gt;

&lt;p&gt;sb.append("Hello");&lt;br&gt;
sb.append(" World");&lt;/p&gt;

&lt;p&gt;String result = sb.toString();&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Methods&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;sb.insert(5, " Java");&lt;br&gt;
sb.delete(5, 10);&lt;br&gt;
sb.reverse();&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. StringBuffer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;StringBuffer is similar to StringBuilder.&lt;/p&gt;

&lt;p&gt;Difference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is synchronized (thread-safe).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;StringBuffer sbuf = new StringBuffer();&lt;/p&gt;

&lt;p&gt;sbuf.append("Thread-safe");&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Performance Difference&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Inefficient&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;String s = "";&lt;/p&gt;

&lt;p&gt;for (int i = 0; i &amp;lt; 10000; i++) {&lt;br&gt;
    s += i;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Efficient&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;StringBuilder sb = new StringBuilder();&lt;/p&gt;

&lt;p&gt;for (int i = 0; i &amp;lt; 10000; i++) {&lt;br&gt;
    sb.append(i);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;String result = sb.toString();&lt;/p&gt;

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

&lt;p&gt;When strings change frequently:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mutable objects are much more efficient.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s why:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;StringBuilder is preferred in most cases&lt;/li&gt;
&lt;li&gt;&lt;p&gt;StringBuffer is used when thread safety matters&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;String = immutable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;StringBuilder = mutable + fast&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;StringBuffer = mutable + thread-safe&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

</description>
      <category>java</category>
      <category>javascript</category>
      <category>algorithms</category>
      <category>database</category>
    </item>
    <item>
      <title>Java String Manipulation Made Simple</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Sat, 16 May 2026 05:49:25 +0000</pubDate>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e/java-string-manipulation-made-simple-3cgg</link>
      <guid>https://dev.to/quipoin_a9cb84280f6225b1e/java-string-manipulation-made-simple-3cgg</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%2Fep4ef1gw6fdpi089ztia.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%2Fep4ef1gw6fdpi089ztia.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
String questions are everywhere in coding interviews.&lt;/p&gt;

&lt;p&gt;And most of them are built on a few simple patterns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Two pointers&lt;/li&gt;
&lt;li&gt;Character arrays&lt;/li&gt;
&lt;li&gt;StringBuilder&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Master these, and many problems become easy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Reverse a String&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The easiest way:&lt;/p&gt;

&lt;p&gt;public static String reverse(String str) {&lt;br&gt;
    return new StringBuilder(str).reverse().toString();&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Manual Reverse&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;public static String reverseManual(String str) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;char[] arr = str.toCharArray();

int left = 0, right = arr.length - 1;

while (left &amp;lt; right) {

    char temp = arr[left];
    arr[left] = arr[right];
    arr[right] = temp;

    left++;
    right--;
}

return new String(arr);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

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

&lt;p&gt;Use two pointers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;one from start&lt;/li&gt;
&lt;li&gt;one from end&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Swap characters until middle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Check Palindrome&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A palindrome reads the same forwards and backwards.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;madam&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;level&lt;br&gt;
public static boolean isPalindrome(String str) {&lt;/p&gt;

&lt;p&gt;int left = 0, right = str.length() - 1;&lt;/p&gt;

&lt;p&gt;while (left &amp;lt; right) {&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (str.charAt(left) != str.charAt(right))
    return false;

left++;
right--;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;return true;&lt;br&gt;
}&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Two Pointers Work&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Compare:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;first ↔ last&lt;/li&gt;
&lt;li&gt;second ↔ second-last&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If all match:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;palindrome confirmed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Remove Duplicate Characters&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;public static String removeDuplicates(String str) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set&amp;lt;Character&amp;gt; seen = new LinkedHashSet&amp;lt;&amp;gt;();

for (char c : str.toCharArray()) {
    seen.add(c);
}

StringBuilder sb = new StringBuilder();

for (char c : seen)
    sb.append(c);

return sb.toString();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;&lt;strong&gt;Why LinkedHashSet?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;removes duplicates&lt;/li&gt;
&lt;li&gt;preserves insertion order&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most string problems involve:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;traversing characters&lt;/li&gt;
&lt;li&gt;comparing from both ends&lt;/li&gt;
&lt;li&gt;&lt;p&gt;building new strings efficiently&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Strings are immutable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;StringBuilder improves efficiency&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Two-pointer technique is powerful for strings&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

</description>
      <category>java</category>
      <category>algorithms</category>
      <category>api</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Why Java Strings Are Immutable — And Why It Matters</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Fri, 15 May 2026 04:48:09 +0000</pubDate>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e/why-java-strings-are-immutable-and-why-it-matters-49jf</link>
      <guid>https://dev.to/quipoin_a9cb84280f6225b1e/why-java-strings-are-immutable-and-why-it-matters-49jf</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%2Fbn6yillqbponwp493u37.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%2Fbn6yillqbponwp493u37.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Strings look simple…&lt;/p&gt;

&lt;p&gt;But Java Strings hide some very important concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Immutability&lt;/li&gt;
&lt;li&gt;String Pool&lt;/li&gt;
&lt;li&gt;Memory optimization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And interviewers LOVE asking about them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a String?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A String is a sequence of characters.&lt;/p&gt;

&lt;p&gt;In Java:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Strings are objects of the String class.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;String name = "Java";&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Strings Are Immutable&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once a String is created:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Its value cannot be changed.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;String s = "Hello";&lt;br&gt;
s = s + " World";&lt;/p&gt;

&lt;p&gt;This creates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Old object → "Hello"&lt;/li&gt;
&lt;li&gt;New object → "Hello World"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The original string remains unchanged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;String Pool Explained&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java stores string literals inside a special memory area called the String Pool.&lt;/p&gt;

&lt;p&gt;String s1 = "Hello";&lt;br&gt;
String s2 = "Hello";&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Both variables point to the same pooled string.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This saves memory and improves performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important String Methods&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;String str = "  Java DSA  ";&lt;/p&gt;

&lt;p&gt;str.length();&lt;br&gt;
str.trim();&lt;br&gt;
str.toUpperCase();&lt;br&gt;
str.charAt(2);&lt;br&gt;
str.indexOf("DSA");&lt;br&gt;
str.substring(2, 9);&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;equals() vs ==&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is one of the most common beginner mistakes.&lt;/p&gt;

&lt;p&gt;String a = new String("Java");&lt;br&gt;
String b = new String("Java");&lt;/p&gt;

&lt;p&gt;System.out.println(a == b);      // false&lt;br&gt;
System.out.println(a.equals(b)); // true&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;== compares references&lt;/li&gt;
&lt;li&gt;equals() compares content&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Java Strings are designed this way for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Security&lt;/li&gt;
&lt;li&gt;Memory optimization&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Thread safety&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Strings are immutable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;String literals use pooling&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use equals() for comparison&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

</description>
      <category>java</category>
      <category>stringsinjava</category>
      <category>dsa</category>
      <category>coding</category>
    </item>
    <item>
      <title>Matrix Problems Explained Simply (Java + Intuition)</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Wed, 13 May 2026 05:28:35 +0000</pubDate>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e/matrix-problems-explained-simply-java-intuition-14aj</link>
      <guid>https://dev.to/quipoin_a9cb84280f6225b1e/matrix-problems-explained-simply-java-intuition-14aj</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%2Fw185r6wchze9tj15iy9l.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%2Fw185r6wchze9tj15iy9l.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
Matrix problems often look intimidating.&lt;/p&gt;

&lt;p&gt;Too many rows, columns, indices…&lt;/p&gt;

&lt;p&gt;But most interview questions are built on just a few core patterns.&lt;/p&gt;

&lt;p&gt;Master these patterns once,&lt;br&gt;
and matrix questions become much easier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Spiral Traversal&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Print matrix elements in spiral order.&lt;/p&gt;

&lt;p&gt;public static List spiralOrder(int[][] matrix) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List&amp;lt;Integer&amp;gt; result = new ArrayList&amp;lt;&amp;gt;();

int top = 0, bottom = matrix.length - 1;
int left = 0, right = matrix[0].length - 1;

while (top &amp;lt;= bottom &amp;amp;&amp;amp; left &amp;lt;= right) {

    for (int i = left; i &amp;lt;= right; i++)
        result.add(matrix[top][i]);

    top++;

    for (int i = top; i &amp;lt;= bottom; i++)
        result.add(matrix[i][right]);

    right--;

    if (top &amp;lt;= bottom) {
        for (int i = right; i &amp;gt;= left; i--)
            result.add(matrix[bottom][i]);

        bottom--;
    }

    if (left &amp;lt;= right) {
        for (int i = bottom; i &amp;gt;= top; i--)
            result.add(matrix[i][left]);

        left++;
    }
}

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

&lt;/div&gt;

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

&lt;p&gt;&lt;strong&gt;Core Idea&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Maintain 4 boundaries:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;top&lt;/li&gt;
&lt;li&gt;bottom&lt;/li&gt;
&lt;li&gt;left&lt;/li&gt;
&lt;li&gt;&lt;p&gt;right&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Move inward layer by layer.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Rotate Matrix by 90°&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Trick&lt;/em&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Transpose matrix&lt;/li&gt;
&lt;li&gt;Reverse each row&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;public static void rotate(int[][] matrix) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Transpose
for (int i = 0; i &amp;lt; matrix.length; i++) {
    for (int j = i; j &amp;lt; matrix[0].length; j++) {

        int temp = matrix[i][j];
        matrix[i][j] = matrix[j][i];
        matrix[j][i] = temp;
    }
}

// Reverse rows
for (int i = 0; i &amp;lt; matrix.length; i++) {

    int left = 0, right = matrix[0].length - 1;

    while (left &amp;lt; right) {

        int temp = matrix[i][left];
        matrix[i][left] = matrix[i][right];
        matrix[i][right] = temp;

        left++;
        right--;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;&lt;strong&gt;Why It Works&lt;/strong&gt;&lt;/p&gt;

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

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

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

&lt;ul&gt;
&lt;li&gt;Adjust orientation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Together:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;90° clockwise rotation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Set Matrix Zeroes&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;If one element is zero:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Entire row &amp;amp; column become zero.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Smart Optimization&lt;/em&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;First row&lt;/li&gt;
&lt;li&gt;First column&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;as markers instead of extra space.&lt;/p&gt;

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

&lt;p&gt;Matrix problems are mostly about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Direction handling&lt;/li&gt;
&lt;li&gt;Boundary management&lt;/li&gt;
&lt;li&gt;Smart index manipulation&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;Spiral → boundaries&lt;/li&gt;
&lt;li&gt;Rotate → transpose + reverse&lt;/li&gt;
&lt;li&gt;Zeroes → marker optimization&lt;/li&gt;
&lt;/ul&gt;

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

</description>
      <category>dsa</category>
      <category>datastructures</category>
      <category>java</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>The Smart O(n) Trick for Subarray Sum Questions</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Tue, 12 May 2026 04:53:08 +0000</pubDate>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e/the-smart-on-trick-for-subarray-sum-questions-5i4</link>
      <guid>https://dev.to/quipoin_a9cb84280f6225b1e/the-smart-on-trick-for-subarray-sum-questions-5i4</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%2Fmh4zgskgha5iz4hu35hy.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%2Fmh4zgskgha5iz4hu35hy.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Subarray problems are everywhere in coding interviews.&lt;/p&gt;

&lt;p&gt;And most beginners solve them using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nested loops&lt;/li&gt;
&lt;li&gt;O(n²) brute force&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But interviewers expect something smarter.&lt;/p&gt;

&lt;p&gt;That’s where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prefix Sum&lt;/li&gt;
&lt;li&gt;HashMap&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;become powerful together.&lt;/p&gt;

&lt;p&gt;Core Idea&lt;/p&gt;

&lt;p&gt;Instead of recalculating sums repeatedly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Store running sums (prefix sums)&lt;/li&gt;
&lt;li&gt;Use hashing for quick lookup&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This reduces many problems to O(n).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Subarray Sum Equals K&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Find number of subarrays whose sum equals k.&lt;/p&gt;

&lt;p&gt;public static int subarraySum(int[] nums, int k) {&lt;br&gt;
    Map map = new HashMap&amp;lt;&amp;gt;();&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;map.put(0, 1);

int sum = 0, count = 0;

for (int num : nums) {
    sum += num;

    int diff = sum - k;

    count += map.getOrDefault(diff, 0);

    map.put(sum, map.getOrDefault(sum, 0) + 1);
}

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

&lt;/div&gt;

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

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

&lt;p&gt;If:&lt;/p&gt;

&lt;p&gt;prefixSum−previousPrefix=k&lt;/p&gt;

&lt;p&gt;Then:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A valid subarray exists.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Zero Sum Subarray&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Check if any subarray has sum = 0.&lt;/p&gt;

&lt;p&gt;public static boolean hasZeroSumSubarray(int[] nums) {&lt;br&gt;
    Set set = new HashSet&amp;lt;&amp;gt;();&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int sum = 0;

for (int num : nums) {
    sum += num;

    if (sum == 0 || set.contains(sum))
        return true;

    set.add(sum);
}

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

&lt;/div&gt;

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

&lt;p&gt;&lt;em&gt;Why It Works&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If the same prefix sum appears twice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Middle subarray sum = 0&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Longest Subarray with Sum K&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Idea&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Store the first occurrence of each prefix sum.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Helps maximize length.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Most subarray problems become easier when you think in terms of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Running sums&lt;/li&gt;
&lt;li&gt;Differences between prefix sums&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;Prefix sum + HashMap = powerful pattern&lt;/li&gt;
&lt;li&gt;Avoids nested loops&lt;/li&gt;
&lt;li&gt;Many interview problems use this idea&lt;/li&gt;
&lt;/ul&gt;

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

</description>
      <category>react</category>
      <category>tailwindcss</category>
      <category>java</category>
      <category>javascript</category>
    </item>
    <item>
      <title>3 Pointers, One Pass: The Smart Sorting Trick</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Tue, 05 May 2026 08:29:15 +0000</pubDate>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e/3-pointers-one-pass-the-smart-sorting-trick-49mo</link>
      <guid>https://dev.to/quipoin_a9cb84280f6225b1e/3-pointers-one-pass-the-smart-sorting-trick-49mo</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%2Fy9boa6bwgagshskkzmzt.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%2Fy9boa6bwgagshskkzmzt.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Sorting usually means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;O(n log n)&lt;/li&gt;
&lt;li&gt;Extra space&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But what if the array contains only 3 distinct values?&lt;/p&gt;

&lt;p&gt;You can sort it in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;O(n) time&lt;/li&gt;
&lt;li&gt;O(1) space&lt;/li&gt;
&lt;li&gt;Single pass&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s the Dutch National Flag Algorithm.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Core Idea&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use three pointers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;low → boundary for 0s&lt;/li&gt;
&lt;li&gt;mid → current element&lt;/li&gt;
&lt;li&gt;high → boundary for 2s&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;public static void sortColors(int[] nums) {&lt;br&gt;
    int low = 0, mid = 0, high = nums.length - 1;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (mid &amp;lt;= high) {
    switch (nums[mid]) {
        case 0:
            swap(nums, low, mid);
            low++; mid++;
            break;

        case 1:
            mid++;
            break;

        case 2:
            swap(nums, mid, high);
            high--;
            break;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
private static void swap(int[] arr, int i, int j) {&lt;br&gt;
    int temp = arr[i];&lt;br&gt;
    arr[i] = arr[j];&lt;br&gt;
    arr[j] = temp;&lt;br&gt;
}&lt;/p&gt;

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

&lt;p&gt;At each step:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If 0 → move to left&lt;/li&gt;
&lt;li&gt;If 1 → keep in middle&lt;/li&gt;
&lt;li&gt;If 2 → move to right&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All done in one traversal&lt;/p&gt;

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

&lt;p&gt;Instead of sorting, we partition the array&lt;/p&gt;

&lt;p&gt;This is similar to Quick Sort partitioning.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Three-pointer technique&lt;/li&gt;
&lt;li&gt;In-place sorting&lt;/li&gt;
&lt;li&gt;Single pass solution&lt;/li&gt;
&lt;/ul&gt;

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

</description>
      <category>java</category>
      <category>coding</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Stop Using Extra Space: Master Moore’s Voting Algorithm</title>
      <dc:creator>Quipoin</dc:creator>
      <pubDate>Sun, 03 May 2026 05:23:11 +0000</pubDate>
      <link>https://dev.to/quipoin_a9cb84280f6225b1e/stop-using-extra-space-master-moores-voting-algorithm-2e4o</link>
      <guid>https://dev.to/quipoin_a9cb84280f6225b1e/stop-using-extra-space-master-moores-voting-algorithm-2e4o</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%2F2i3pdgjrmsel2b47geys.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%2F2i3pdgjrmsel2b47geys.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Finding the majority element seems easy…&lt;/p&gt;

&lt;p&gt;Just count frequencies, right?&lt;/p&gt;

&lt;p&gt;But that takes extra space.&lt;/p&gt;

&lt;p&gt;What if you could solve it in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;O(n) time&lt;/li&gt;
&lt;li&gt;O(1) space&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s where Moore’s Voting Algorithm shines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Core Idea&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The algorithm works like cancelling votes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Different elements cancel each other&lt;/li&gt;
&lt;li&gt;Majority element survives&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Phase 1: Candidate Selection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;int candidate = 0, count = 0;&lt;/p&gt;

&lt;p&gt;for (int num : nums) {&lt;br&gt;
    if (count == 0) {&lt;br&gt;
        candidate = num;&lt;br&gt;
        count = 1;&lt;br&gt;
    } else if (num == candidate) {&lt;br&gt;
        count++;&lt;br&gt;
    } else {&lt;br&gt;
        count--;&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Think of it as:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Same element → increase count&lt;/li&gt;
&lt;li&gt;Different element → cancel&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Phase 2: Verification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;count = 0;&lt;br&gt;
for (int num : nums) {&lt;br&gt;
    if (num == candidate) count++;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;if (count &amp;gt; nums.length / 2) return candidate;&lt;br&gt;
return -1;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensures candidate is actually majority&lt;/li&gt;
&lt;/ul&gt;

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

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

&lt;p&gt;[3, 3, 4, 2, 3, 3, 3]&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Majority element = 3&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Majority element can’t be fully cancelled&lt;/p&gt;

&lt;p&gt;Because it appears more than half the time.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Uses vote cancellation logic&lt;/li&gt;
&lt;li&gt;Requires two passes&lt;/li&gt;
&lt;li&gt;No extra space needed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;for more: &lt;a href="https://www.quipoin.com/tutorial/data-structure-with-java/moore-voting-algorithm" rel="noopener noreferrer"&gt;https://www.quipoin.com/tutorial/data-structure-with-java/moore-voting-algorithm&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>vite</category>
      <category>npm</category>
      <category>devplusplus</category>
    </item>
  </channel>
</rss>
