Free reference library
Coding Interview Pattern Guides
Clear explanations of the most reusable coding interview patterns, with worked examples, code templates, common mistakes, and practice directions. Every guide is free and stands on its own.
Pattern guide library
Sliding Window
Maintain a contiguous range without recomputing it from scratch. Learn fixed and variable windows, expand and shrink rules, and the cases where negative values break sum-based windows.
- Fixed and variable windows
- Window state and invariants
- Expand and shrink templates
Two Pointers
Replace repeated scans with boundaries that move for a proved reason. Compare opposite-end, same-direction, fast and slow, and read and write pointer models.
- Pointer placement
- Movement invariants
- Sorted and in-place problems
Prefix Sum
Precompute cumulative state so range totals and subarray relationships become direct lookups. Covers prefix arrays, hash-map combinations, and difference arrays.
- Range queries
- Prefix sum plus hash map
- Difference arrays
Binary Search
Search sorted data and monotonic decision spaces with explicit boundary meaning. Learn exact search, first and last true boundaries, and rotated-array variations.
- Boundary definitions
- First and last occurrence
- Rotated arrays
Hash Maps
Trade repeated lookup work for stored information. Learn frequency maps, complement lookups, grouping, visited state, and when a set is enough.
- Frequency counting
- One-pass lookups
- Sets versus maps
Depth-First Search
Explore one branch completely before returning. Covers recursive and iterative traversal, tree return values, graph visited state, components, and cycle handling.
- Trees and graphs
- Visited state
- Recursive return values
Breadth-First Search
Process a graph frontier in distance layers. Learn queue mechanics, seen-on-enqueue, shortest unweighted paths, multi-source search, and state-space modeling.
- Distance layers
- Shortest unweighted paths
- Multi-source BFS
Stacks
Keep unresolved work in last-in, first-out order. Covers matching and nesting, monotonic stacks, expression problems, and stack-based simulations.
- Matching and nesting
- Monotonic stacks
- Expression evaluation
Linked Lists
Change references without losing the rest of the structure. Learn reversal, dummy nodes, fast and slow pointers, cycle detection, and list merging.
- Reference-safe reversal
- Dummy nodes
- Fast and slow pointers
Heaps and Priority Queues
Maintain the next best candidate as data changes. Covers min and max heaps, bounded top-k structures, k-way merge, and streaming problems.
- Min heap versus max heap
- Top-k problems
- K-way merge
Greedy Algorithms
Commit to a local choice only when it cannot damage the best global result. Learn recognition, exchange arguments, staying-ahead proofs, and failure cases.
- Greedy-choice property
- Correctness arguments
- Counterexamples
Intervals
Sort ranges into an order that makes overlap decisions local. Covers merging, insertion, scheduling, room counts, and endpoint tie handling.
- Merge and insert
- Scheduling
- Endpoint sweeps
Backtracking
Explore a decision tree while restoring shared state before the next choice. Learn subsets, permutations, combinations, pruning, and constraint search.
- Choose, recurse, undo
- Choice boundaries
- Pruning
Tries
Store strings by shared character prefixes. Covers trie nodes, insertion, exact and prefix search, autocomplete, and trie-backed board search.
- Prefix-tree structure
- Insert and search
- Trie plus DFS
Union Find
Track changing connectivity without retraversing the whole graph. Learn parent links, path compression, union by size, and cycle detection.
- Find and union
- Path compression
- Dynamic connectivity
Dynamic Programming
Define what one state answers, derive its recurrence, and evaluate dependencies in a valid order. Covers memoization, tabulation, and major DP families.
- State and recurrence
- Memoization and tabulation
- DP families
Want an ordered path instead?
Pattern Guides are references. The Interview Course sequences the concepts, examples, and problems so each skill builds on the previous one.