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.
Maintains a contiguous window over an array or string that expands and shrinks to find optimal sub-ranges in linear time.
Iterates with two references converging from ends or moving toward a target in a sorted collection.
Moves two pointers at different speeds (Floyd's algorithm) to inspect cyclical behaviors and linked structures with O(1) space.
Sorts overlapping intervals by start time and consolidates overlapping ranges into unified bounds.
Places elements in range [1, n] directly at index (value - 1) in linear time using minimal in-place swaps.
Reverses sub-segments of linked lists by manipulating pointer references without allocating additional memory nodes.
Processes tree and graph structures level-by-level using a FIFO Queue to examine shortest distances and level statistics.
Traverses deeply down branches recursively (or with an explicit stack) to inspect root-to-leaf paths and subtree heights.
Maintains two balanced priority queues (Max-Heap for lower half, Min-Heap for upper half) to query dynamic medians.
Explores all possible choices systematically via recursion, choosing an element, recurring, and undoing the choice.
Discards half of the remaining search space per step on sorted arrays, rotated arrays, or monotonic answer functions in O(log N).
Keeps a bounded Min-Heap of size K while iterating over N elements to extract extreme values in O(N log K) time.
Inserts the first element of K sorted lists into a Min-Heap and repeatedly extracts the smallest element to build a unified stream.
Models optimal choice decisions where items can either be included or excluded, memoizing state to prevent recomputation.
Finds a linear sequence of tasks respecting directed prerequisite dependencies in a Directed Acyclic Graph (DAG) using Kahn's algorithm.