Curated Study Hub

Patterns, Frameworks & Master Study Guides

Stop grinding random problems in the dark. Use community-tested mental models: the 5-step DP breakdown, universal sliding window templates, machine coding blueprints, and real FAANG interview debriefs.

15 Canonical Coding Interview Patterns

Each pattern links to the exact tutorial to learn the mental model, plus matching questions on our catalogue.

Sliding WindowLearn Pattern

Maintains a contiguous window over an array or string that expands and shrinks to find optimal sub-ranges in linear time.

When to use: Problem involves finding the longest, shortest, or target-sum contiguous subarray/substring.
Two PointersLearn Pattern

Iterates with two references converging from ends or moving toward a target in a sorted collection.

When to use: Sorted arrays/lists, searching for pairs with a target sum, reversing in-place, or verifying palindromes.
Fast & Slow PointersLearn Pattern

Moves two pointers at different speeds (Floyd's algorithm) to inspect cyclical behaviors and linked structures with O(1) space.

When to use: Detecting cycles in linked lists, finding middle node, or finding the duplicate number without mutating array.
Merge IntervalsLearn Pattern

Sorts overlapping intervals by start time and consolidates overlapping ranges into unified bounds.

When to use: Meeting rooms scheduling, calendar conflicts, timeline merges, and range overlaps.
Cyclic SortLearn Pattern

Places elements in range [1, n] directly at index (value - 1) in linear time using minimal in-place swaps.

When to use: Finding missing, duplicate, or corrupted numbers within a 1-to-N or 0-to-N bounded array.
In-place Reversal of LinkedListLearn Pattern

Reverses sub-segments of linked lists by manipulating pointer references without allocating additional memory nodes.

When to use: Reversing entire linked list, reversing in K-groups, or reversing between positions m and n.
Tree Breadth-First Search (BFS)Learn Pattern

Processes tree and graph structures level-by-level using a FIFO Queue to examine shortest distances and level statistics.

When to use: Level order traversal, level averages, right side view, or zig-zag level order.
Tree Depth-First Search (DFS)Learn Pattern

Traverses deeply down branches recursively (or with an explicit stack) to inspect root-to-leaf paths and subtree heights.

When to use: Calculating maximum tree depth, root-to-leaf path sums, diameter, and lowest common ancestor.
Two Heaps (Min/Max Heap)Learn Pattern

Maintains two balanced priority queues (Max-Heap for lower half, Min-Heap for upper half) to query dynamic medians.

When to use: Finding running median of a data stream or balancing sliding windows of continuous metrics.
Subsets & BacktrackingLearn Pattern

Explores all possible choices systematically via recursion, choosing an element, recurring, and undoing the choice.

When to use: Power sets, permutations, combinations, sudoku, N-Queens, and word search.
Modified Binary SearchLearn Pattern

Discards half of the remaining search space per step on sorted arrays, rotated arrays, or monotonic answer functions in O(log N).

When to use: Searching in rotated sorted arrays, finding boundary conditions, or optimization problems with monotonic feasibility.
Top 'K' ElementsLearn Pattern

Keeps a bounded Min-Heap of size K while iterating over N elements to extract extreme values in O(N log K) time.

When to use: Finding K largest, K smallest, or K most frequent elements without doing a full O(N log N) sort.
K-way MergeLearn Pattern

Inserts the first element of K sorted lists into a Min-Heap and repeatedly extracts the smallest element to build a unified stream.

When to use: Merging multiple sorted linked lists, arrays, or sorted matrix searches.
0/1 Knapsack & Dynamic ProgrammingLearn Pattern

Models optimal choice decisions where items can either be included or excluded, memoizing state to prevent recomputation.

When to use: Subset sum partitions, target sums, minimum coin changes, and discrete resource allocation.
Topological SortLearn Pattern

Finds a linear sequence of tasks respecting directed prerequisite dependencies in a Directed Acyclic Graph (DAG) using Kahn's algorithm.

When to use: Build dependency resolution, course prerequisites, alien dictionaries, and task scheduling.