Two Pointers Pattern

Array Patterns - The Complete Study Guide

🗺️ Array Patterns - The Complete Study Guide Welcome This is a structured, beginner-friendly study guide for mastering array and string patterns - the building blocks of coding interviews. Each pattern has a dedicated deep-dive document with theory, intuition, templates, and 10 LeetCode problems solved step by step. Who is this for? You’re preparing for coding interviews and want a systematic approach You can solve easy problems but struggle to recognize which technique to apply You want to understand why an approach works, not just memorize solutions How to use this guide: ...

March 21, 2026 · 6 min · 1229 words ·  · By codeverra
Binary Search Pattern

Binary Search Pattern - Complete Guide

🔰 Pattern 2: Binary Search Table of Contents What is Binary Search? The Core Idea - Why Halving Works The Three Binary Search Templates Binary Search on Answer - The Hidden Pattern Common Pitfalls Problem Set Problem 1: Binary Search Problem 2: Search Insert Position Problem 3: Find First and Last Position of Element in Sorted Array Problem 4: Search a 2D Matrix Problem 5: Search in Rotated Sorted Array Problem 6: Find Minimum in Rotated Sorted Array Problem 7: Koko Eating Bananas Problem 8: Capacity to Ship Packages Within D Days Problem 9: Split Array Largest Sum Problem 10: Median of Two Sorted Arrays Key Takeaways & Summary What is Binary Search? In the Two Pointers pattern, we used two indices to narrow down a search space. Binary search takes that idea to its most powerful form: instead of narrowing one step at a time, we cut the search space in half at every step. ...

March 21, 2026 · 37 min · 7715 words ·  · By codeverra
Hashmap Frequency Pattern

HashMap and Frequency Counting Pattern - Complete Guide

🔰 Pattern 4: HashMap / Frequency Counting Table of Contents What is the HashMap Pattern? When to Use HashMaps? Types of HashMap Patterns Template Code Problem Set Problem 1: Two Sum Problem 2: Valid Anagram Problem 3: Group Anagrams Problem 4: Top K Frequent Elements Problem 5: Longest Consecutive Sequence Problem 6: Contains Duplicate II Problem 7: Intersection of Two Arrays II Problem 8: First Unique Character in a String Problem 9: 4Sum II Problem 10: Encode and Decode TinyURL Key Takeaways & Summary What is the HashMap Pattern? In the previous patterns, we’ve already used hashmaps as a supporting tool - tracking character frequencies in sliding window, storing prefix sums for subarray problems. In this section, we focus on problems where the hashmap is the core of the solution, not just a helper. ...

March 21, 2026 · 36 min · 7599 words ·  · By codeverra
Prefix Sum Pattern

Prefix Sum Pattern - Complete Guide

🔰 Pattern 3: Prefix Sum Table of Contents What is Prefix Sum? Building the Intuition Step by Step The Range Sum Formula - Why It Works Common Variations Template Code Problem Set Problem 1: Range Sum Query – Immutable Problem 2: Running Sum of 1D Array Problem 3: Find Pivot Index Problem 4: Subarray Sum Equals K Problem 5: Contiguous Array Problem 6: Product of Array Except Self Problem 7: Subarray Sums Divisible by K Problem 8: Range Sum Query 2D – Immutable Problem 9: Continuous Subarray Sum Problem 10: Count Number of Nice Subarrays Key Takeaways & Summary What is Prefix Sum? Consider this scenario: you have an array of numbers and someone keeps asking you “what’s the sum of elements from index i to index j?” - not once, but hundreds of times with different i and j values. ...

March 21, 2026 · 41 min · 8588 words ·  · By codeverra
Sliding Window Pattern

Sliding Window Pattern - Complete Guide

🔰 Pattern 2: Sliding Window Table of Contents What is the Sliding Window Technique? When to Use Sliding Window? Types of Sliding Window Template Code Problem Set Problem 1: Maximum Sum Subarray of Size K Problem 2: Longest Substring Without Repeating Characters Problem 3: Maximum Average Subarray I Problem 4: Minimum Size Subarray Sum Problem 5: Permutation in String Problem 6: Longest Repeating Character Replacement Problem 7: Fruit Into Baskets Problem 8: Minimum Window Substring Problem 9: Sliding Window Maximum Problem 10: Substring with Concatenation of All Words Key Takeaways & Summary What is the Sliding Window Technique? In the Two Pointers pattern, we learned how two indices can traverse an array efficiently. Sliding Window builds on that idea - it maintains a range (window) between two pointers and cares about the elements inside that range. ...

March 21, 2026 · 42 min · 8899 words ·  · By codeverra
Two Pointers Pattern

Two Pointers Pattern - Complete Guide

🔰 Pattern 1: Two Pointers Table of Contents What is the Two Pointer Technique? When to Use Two Pointers? Types of Two Pointer Patterns Visual Walkthrough Template Code Problem Set Problem 1: Two Sum II – Input Array Is Sorted Problem 2: Valid Palindrome Problem 3: Remove Duplicates from Sorted Array Problem 4: Container With Most Water Problem 5: 3Sum Problem 6: Trapping Rain Water Problem 7: Sort Colors (Dutch National Flag) Problem 8: Move Zeroes Problem 9: Squares of a Sorted Array Problem 10: Merge Sorted Array Key Takeaways & Summary What is the Two Pointer Technique? Two Pointers is a technique where you use two index variables that move through an array or string - either toward each other from opposite ends, or in the same direction at different speeds - to solve a problem efficiently. ...

March 21, 2026 · 36 min · 7464 words ·  · By codeverra