Algorithm & Data Structure Cheat Sheets

137 sheets, ranked by how often the pattern actually shows up in a FAANG software-engineering loop. Follow the review path to work through the ones that matter in order, or browse by priority or topic.

Review path

59 core sheets in study order — the 12 foundations first, then every other must-know sheet, then the high-value ones. Mark a sheet reviewed when you have re-read its starred templates; it comes due again a week later (two for high value).

Foundations12 sheets

The reading ladder: each one unlocks the next.

  1. LeetCode Pattern GuidePriority 5 of 5 — Must know — expect it in almost every loop

    The front door: signal in the statement → pattern → the card that solves it.

    drill 14/27 ok · 11 again · next: LC 206, LC 322, LC 347

  2. Complexity Cheat SheetPriority 5 of 5 — Must know — expect it in almost every loop

    You will be asked to state complexity in every round.

    no drill path yet

  3. ArrayPriority 5 of 5 — Must know — expect it in almost every loop+ examples

    In-place rewriting and the index-as-hash trick.

    drill 4/15 ok · 3 again · next: LC 88, LC 2657, LC 41

  4. Hash MapPriority 5 of 5 — Must know — expect it in almost every loop+ examples

    The single most-used structure in interviews.

    drill 5/16 ok · 4 again · next: LC 347, LC 146, LC 438

  5. Two PointersPriority 5 of 5 — Must know — expect it in almost every loop+ examples

    Converging and trailing pointers on arrays/strings.

    drill 8/16 ok · 4 again · next: LC 5, LC 647, LC 88

  6. Sliding WindowPriority 5 of 5 — Must know — expect it in almost every loop+ examples

    Expand/contract on a condition — a whole question family.

    drill 5/14 ok · 4 again · next: LC 438, LC 4067, LC 992

  7. Binary SearchPriority 5 of 5 — Must know — expect it in almost every loop+ examples

    Boundary templates, plus binary search on the answer.

    drill 8/20 ok · 4 again · next: LC 300, LC 35, LC 702

  8. Binary TreePriority 5 of 5 — Must know — expect it in almost every loop

    How DFS state flows down and back up a tree.

    drill 13/20 ok · 5 again · next: LC 572, LC 222, LC 652

  9. BFS (Breadth-First Search)Priority 5 of 5 — Must know — expect it in almost every loop+ examples

    Level order, and why it gives shortest paths.

    drill 4/13 ok · 3 again · next: LC 542, LC 785, LC 752

  10. DFS (Depth-First Search)Priority 5 of 5 — Must know — expect it in almost every loop+ examples

    The recursion patterns every graph/tree question reuses.

    drill 9/20 ok · 7 again · next: LC 417, LC 124, LC 101

  11. Heap & Priority QueuePriority 5 of 5 — Must know — expect it in almost every loop+ examples

    Top-k and "repeatedly take the best" problems.

    drill 5/18 ok · 6 again · next: LC 347, LC 23, LC 703

  12. Dynamic Programming (DP)Priority 5 of 5 — Must know — expect it in almost every loop+ examples

    The largest and hardest tier-5 block — budget the most time here.

    drill 11/30 ok · 14 again · next: LC 91, LC 139, LC 300

Must know12 sheets

The rest of what shows up in almost every loop.

  1. StringsPriority 5 of 5 — Must know — expect it in almost every loop+ examples

    The everyday string catalogue — character-level two-pointer scans, frequency and anagram signatures, run-length grouping, tokenising, parsing and in-place rewriting — while the worked-solution archive, the language-level string API, palindromes, substring search and two-sequence DP each live in their own sheet.

    drill 3/13 ok · 3 again · next: LC 696, LC 388, LC 71

  2. StackPriority 5 of 5 — Must know — expect it in almost every loop+ examples

    LIFO fundamentals and the canonical stack templates: bracket matching, min-stack, the short monotonic-stack form, explicit-stack traversal and the scope/context ledger.

    drill 2/12 ok · 5 again · next: LC 155, LC 232, LC 636

  3. Linked ListPriority 5 of 5 — Must know — expect it in almost every loop+ examples

    Pointer surgery on singly and doubly linked lists — reversal, merging, reordering, dummy-head technique, and cycle handling.

    drill 4/23 ok · 10 again · next: LC 206, LC 19, LC 143

  4. BST (Binary Search Tree)Priority 5 of 5 — Must know — expect it in almost every loop+ examples

    Ordered trees only — what the left < root < right invariant buys you (O(log n) search, sorted inorder, range pruning, order statistics).

    drill 4/12 ok · 5 again · next: LC 230, LC 450, LC 669

  5. Tree — Concepts & PatternsPriority 5 of 5 — Must know — expect it in almost every loop+ examples

    Tree concepts, tree types and traversal-order strategy — the why and which, plus the advanced techniques that are worked here (Morris threading, binary lifting, and re-rooting DP, the home of LC 834). The per-pattern binary-tree templates live in tree2.md.

    drill 4/10 ok · 2 again · next: LC 297, LC 99, LC 114

  6. Tree LCA, Distance & Path ProblemsPriority 5 of 5 — Must know — expect it in almost every loop

    Lowest common ancestor, node-to-node distance, parent-map (bidirectional) traversal and the root-to-leaf path templates — every tree problem whose answer is a path or a meeting point rather than a shape.

    drill 8/14 ok · 5 again · next: LC 124, LC 437, LC 1644

  7. Graph AlgorithmsPriority 5 of 5 — Must know — expect it in almost every loop+ examples

    Graph representation, traversal, connectivity, cycle detection and the general graph-problem catalogue.

    drill 9/18 ok · 3 again · next: LC 269, LC 785, LC 721

  8. Binary Search on the AnswerPriority 5 of 5 — Must know — expect it in almost every loop

    Binary searching a range of candidate answers against a monotone feasibility predicate — the canFinish / isValid framing, the minimise-maximum vs maximise-minimum decision, the [max(nums), sum(nums)] boundary recipe, and counting predicates over a value domain.

    drill 3/14 ok · 5 again · next: LC 1552, LC 378, LC 2616

  9. 0/1 背包 DP(中文)Priority 5 of 5 — Must know — expect it in almost every loop

    用中文把 0/1 背包從「物品重量價值」一路講到 LC 494/416 的解題流程,重點放在 state 怎麼定義、「拿或不拿」的轉移、以及為什麼內層 loop 一定要倒序;完全背包(Unbounded)與排列/組合的 loop 順序規則不在這裡展開。

    no drill path yet

  10. BacktrackingPriority 5 of 5 — Must know — expect it in almost every loop+ examples

    Systematic search with undo: the choose/explore/un-choose skeleton, start_idx control, duplicate skipping, pruning, and exactly one canonical template per must-know shape — the long tail of worked solutions and the hard-tier state-carrying templates live in its two satellites.

    drill 4/23 ok · 5 again · next: LC 39, LC 17, LC 131

  11. Knapsack DPPriority 5 of 5 — Must know — expect it in almost every loop

    The knapsack family in full: 0/1 vs unbounded vs bounded vs group, the subset-sum reduction, why the 0/1 inner loop runs backward, and the loop-order rule that separates combinations from permutations.

    drill 2/13 ok · 6 again · next: LC 322, LC 416, LC 279

  12. Python Operation ComplexityPriority 5 of 5 — Must know — expect it in almost every loop

    What every Python built-in and container operation actually costs, and why: the per-call tables for the built-in functions, list, str, dict/set, tuple, deque, heapq, bisect and int, the CPython layout each cost follows from, and the seven idioms that quietly turn an O(n) solution into an O(n²) one.

    no drill path yet

High value35 sheets

Common enough that a gap here costs a round.

  1. Matrix / 2D GridPriority 4 of 5 — High value — a gap here costs you rounds+ examples

    The 2D grid as its own topic — traversal geometry (spiral, diagonal, rotate, transpose), in-place marking, and index↔coordinate arithmetic.

    no drill path yet

  2. N Sum (2Sum → kSum)Priority 4 of 5 — High value — a gap here costs you rounds

    The k-sum family specifically — 2Sum through kSum, the sort-then-converge recursion, and duplicate handling.

    no drill path yet

  3. PalindromePriority 4 of 5 — High value — a gap here costs you rounds

    The palindrome family — expand-from-center, two-pointer verification, palindromic DP, and Manacher — and how to tell which a problem needs.

    no drill path yet

  4. Prefix SumPriority 4 of 5 — High value — a gap here costs you rounds+ examples

    Prefix / running sums — subarray sums, 2D prefix sums, prefix + hashmap counting.

    no drill path yet

  5. Java Collections — Which to UsePriority 4 of 5 — High value — a gap here costs you rounds

    Cross-collection chooser — which Java / Python container for which job, and the API gotchas of each.

    no drill path yet

  6. Monotonic StackPriority 4 of 5 — High value — a gap here costs you rounds

    Next greater / previous smaller / span / histogram problems — the stack stays sorted so each element is pushed and popped once.

    no drill path yet

  7. Queue Data StructurePriority 4 of 5 — High value — a gap here costs you rounds

    FIFO fundamentals — BFS queues, deques, circular buffers, queue-backed designs.

    no drill path yet

  8. Stack — Expression ParsingPriority 4 of 5 — High value — a gap here costs you rounds

    The stack-based expression family: the calculators (LC 224 / 227 / 772), decode-string style nesting (LC 394) and postfix / sequential-operand evaluation (LC 150, 682), with the pre_op delay-insert trick that makes operator precedence fall out of a plain stack.

    no drill path yet

  9. Two Pointers — Linked ListPriority 4 of 5 — High value — a gap here costs you rounds

    Two pointers over linked-list nodes — fast/slow cycle detection, middle finding, k-th from end, and offset pointers. No array indexing.

    no drill path yet

  10. Tree ConstructionPriority 4 of 5 — High value — a gap here costs you rounds

    Building a binary tree from something flat: two traversal arrays, an index range over one array, or a parenthesised / infix string — the inverse direction of every tree problem that only reads a tree.

    no drill path yet

  11. Tree Pattern TemplatesPriority 4 of 5 — High value — a gap here costs you rounds

    An index from every tree pattern to the one card that teaches it, plus the traversal forms no core sheet spells out: iterative pre- and post-order, zigzag levels, the bottom-left value and vertical order.

    drill 0/8 ok · next: LC 144, LC 145, LC 103

  12. Tree Serialization & String CodecPriority 4 of 5 — High value — a gap here costs you rounds

    Turning a tree into a string and back — subtree fingerprints for identity and duplicate detection, and the full encode/decode codec family (parenthesis, comma plus null marker, depth prefix).

    no drill path yet

  13. TriePriority 4 of 5 — High value — a gap here costs you rounds+ examples

    The prefix tree — insert/search/startsWith, node layout choices, and the problems where sharing prefixes is the whole trick (autocomplete, word search, XOR trie).

    no drill path yet

  14. Dijkstra’s AlgorithmPriority 4 of 5 — High value — a gap here costs you rounds+ examples

    Single-source shortest path with non-negative weights, via a priority queue.

    no drill path yet

  15. Topological SortPriority 4 of 5 — High value — a gap here costs you rounds+ examples

    Ordering a DAG — Kahn's BFS, DFS post-order, cycle detection, and the scheduling problems built on them.

    no drill path yet

  16. Union Find (Disjoint Set)Priority 4 of 5 — High value — a gap here costs you rounds+ examples

    Disjoint set union — connectivity, component counting, cycle detection in undirected graphs, with path compression and union by rank.

    no drill path yet

  17. Patience Sorting (LIS)Priority 4 of 5 — High value — a gap here costs you rounds

    The card-game algorithm behind O(N log N) longest increasing subsequence: the piles, the tails array they collapse to, recovering the subsequence itself, and the problem family that reduces to it.

    no drill path yet

  18. Quickselect (Kth Element by Partition)Priority 4 of 5 — High value — a gap here costs you rounds

    Partition-based selection: finding the kth largest, kth smallest or k closest element in O(n) average time by keeping only one side of a quicksort partition, with the partition schemes it can use and the median-of-medians pivot that makes the worst case linear. It owns LC 215's quickselect answer; the heap answer is in heap.md.

    drill 3/9 ok · 1 again · next: LC 347, LC 1985, LC 1337

  19. Sorting AlgorithmsPriority 4 of 5 — High value — a gap here costs you rounds

    Sorting algorithms and sort-adjacent techniques — comparison sorts and their stability, counting/bucket/radix, quickselect, custom comparators, and cyclic sort.

    no drill path yet

  20. DP Loop Order & DependencyPriority 4 of 5 — High value — a gap here costs you rounds

    Why a bottom-up DP's loop nesting and direction are forced by its own transition, the four ways a wrong order fails, and LC 139 Word Break worked in five orders — including the one that looks right, passes "leetcode", and silently fails the problem's own Example 2.

    no drill path yet

  21. DP Patterns — One-Screen TemplatesPriority 4 of 5 — High value — a gap here costs you rounds

    Template index — one short section per classic DP pattern (Kadane, LIS, MCM, LCS, knapsack, state machine, grid, bitmask, digit, tree DP, regex, interval scheduling, split, memoised DAG).

    no drill path yet

  22. RecursionPriority 4 of 5 — High value — a gap here costs you rounds

    Recursion as a mechanism — base case, state passed down vs returned up, call-stack cost, and converting to iteration. The pattern families that use recursion each have their own file.

    no drill path yet

  23. Recursion → DPPriority 4 of 5 — High value — a gap here costs you rounds

    The mechanical pipeline: recursion → memoisation → tabulation → space-optimised, applied to one problem at a time.

    no drill path yet

  24. String DPPriority 4 of 5 — High value — a gap here costs you rounds

    DP over one or two strings: the dp[m+1][n+1] two-sequence grid, prefix-based (1-indexed) table design, and the worked patterns for LCS, edit distance, interleaving and wildcard/parenthesis matching.

    no drill path yet

  25. Greedy AlgorithmsPriority 4 of 5 — High value — a gap here costs you rounds+ examples

    Taking the locally best choice and the exchange argument that proves it safe — interval scheduling, jump games, task assignment — plus how to spot when greedy fails and DP is required.

    no drill path yet

  26. IntervalsPriority 4 of 5 — High value — a gap here costs you rounds

    Sort-then-merge interval problems — merge, insert, count overlaps, minimum removals.

    no drill path yet

  27. Design (LC "Design a X")Priority 4 of 5 — High value — a gap here costs you rounds+ examples

    LC "design a X" problems — reading the required operations off the problem and picking the structure combination that makes every one of them O(1) or O(log n); the worked designs themselves live in the examples sheet.

    no drill path yet

  28. OOD / Low-Level DesignPriority 4 of 5 — High value — a gap here costs you rounds

    The low-level-design round — class modelling, SOLID, and the design patterns interviewers actually ask for (strategy, observer, factory, state), with worked designs.

    no drill path yet

  29. Java Collections & ArraysPriority 4 of 5 — High value — a gap here costs you rounds

    The Java library APIs for holding data: arrays and 2D arrays, lists, maps, queues, heaps, stacks and pairs — how to initialise, copy, iterate and index each one, and the traps in doing so.

    no drill path yet

  30. Java Strings & SortingPriority 4 of 5 — High value — a gap here costs you rounds

    Java String and StringBuilder work — converting to and from char[], slicing, parsing, building and mutating — together with everything comparator-shaped: array, collection and map sorting, and the return-value rules that decide the order.

    no drill path yet

  31. Java Tricks & IdiomsPriority 4 of 5 — High value — a gap here costs you rounds

    The Java language semantics that decide whether a correct algorithm produces a correct answer: characters as integers, value vs reference, and integer arithmetic. The library APIs live in two companion sheets.

    no drill path yet

  32. Python Insertion, Slicing & Index ArithmeticPriority 4 of 5 — High value — a gap here costs you rounds

    The two things that produce most wrong answers in Python solutions that are otherwise correct: where an insertion actually lands, and whether an index range means a count or a distance.

    no drill path yet

  33. Python Standard LibraryPriority 4 of 5 — High value — a gap here costs you rounds

    The library-by-library reference: heapq, sortedcontainers, the built-in sort (sorted / list.sort), bisect, collections, itertools, functools and datetime — the calls, their complexity, and the idiom each one exists to replace.

    no drill path yet

  34. Python Tricks & IdiomsPriority 4 of 5 — High value — a gap here costs you rounds

    The Python language idioms that come up while solving problems — copying, string handling, sort keys, integer arithmetic, comprehensions and scope — grouped by what you are trying to do. The standard library, the index arithmetic and the cost of each operation have their own sheets.

    no drill path yet

  35. Time & Space ComplexityPriority 4 of 5 — High value — a gap here costs you rounds

    Walkthroughs — how to argue the complexity of an actual LC solution, one classic per technique.

    no drill path yet

By priority

Priority 5 of 5 — Must know — expect it in almost every loopMust know24 sheets

Shows up in almost every FAANG loop — you should be able to write these from memory.

LeetCode Pattern Guide

Priority 5 of 5 — Must know — expect it in almost every loop

Interview Meta

The front door: from a problem statement to the card that solves it — the signal in the wording, the constraint cue, the pattern, a link to its card, and the look-alike that is not it. A router only: every template lives in the card a row links to.

drill 14/27 ok · 11 again · next: LC 206, LC 322, LC 347

Complexity Cheat Sheet

Priority 5 of 5 — Must know — expect it in almost every loop

Interview Meta

Lookup tables — Big-O of every common data structure and classic algorithm, plus the math intuitions behind them.

Array

Priority 5 of 5 — Must know — expect it in almost every loop

Arrays & Strings

Array fundamentals — in-place rewriting, rotation, partitioning, and the index-as-hash trick. Owns the operations; the pattern families (windows, pointers, prefix sums) each have their own file.

drill 4/15 ok · 3 again · next: LC 88, LC 2657, LC 41

Hash Map

Priority 5 of 5 — Must know — expect it in almost every loop

Hashing, Stacks & Queues

Key→value problem patterns — lookup, grouping, index maps, prefix-sum maps, remapping.

drill 5/16 ok · 4 again · next: LC 347, LC 146, LC 438

Two Pointers

Priority 5 of 5 — Must know — expect it in almost every loop

Arrays & Strings

The two-pointer family on arrays and strings — opposite-ends convergence, fast/slow, expand-from-centre and the read/write partition, with one canonical template for each; window problems that grow and shrink on a condition live elsewhere.

drill 8/16 ok · 4 again · next: LC 5, LC 647, LC 88

Sliding Window

Priority 5 of 5 — Must know — expect it in almost every loop

Arrays & Strings

Windows that grow and shrink on a condition — fixed-size, variable-size, at-most-k, and exactly-k by subtraction; owns the expand/contract loop and the seven canonical window templates.

drill 5/14 ok · 4 again · next: LC 438, LC 4067, LC 992

Binary Search

Priority 5 of 5 — Must know — expect it in almost every loop

Search & Sort

Halving a monotonic search space — the loop-invariant reasoning behind l <= r vs l < r, the boundary (lower/upper bound) templates, rotated arrays, and floating-point and 2D search.

drill 8/20 ok · 4 again · next: LC 300, LC 35, LC 702

Binary Tree

Priority 5 of 5 — Must know — expect it in almost every loop

Trees & Heaps

Binary-tree-specific reasoning: which direction DFS state flows (down vs up), plus the 11 structural templates built on that.

drill 13/20 ok · 5 again · next: LC 572, LC 222, LC 652

BFS (Breadth-First Search)

Priority 5 of 5 — Must know — expect it in almost every loop

Graphs

The main BFS reference: the queue templates, level-by-level expansion, grid and multi-source BFS, and why first visit equals shortest path on an unweighted graph; the heavier variants and the long tail of worked problems live in their own sheets.

drill 4/13 ok · 3 again · next: LC 542, LC 785, LC 752

DFS (Depth-First Search)

Priority 5 of 5 — Must know — expect it in almost every loop

Graphs

The main DFS reference: the ten core depth-first templates — tree traversal, grid flood fill, path finding, backtracking, tree modification, post-order aggregation, boundary elimination, shape signatures and weighted-edge traversal — with the recognition table that picks between them.

drill 9/20 ok · 7 again · next: LC 417, LC 124, LC 101

Heap & Priority Queue

Priority 5 of 5 — Must know — expect it in almost every loop

Trees & Heaps

Both the heap (the structure) and the priority queue (the ADT it implements), in Python and Java. Formerly split across heap.md + priority_queue.md, which solved the same problems twice.

drill 5/18 ok · 6 again · next: LC 347, LC 23, LC 703

Dynamic Programming (DP)

Priority 5 of 5 — Must know — expect it in almost every loop

Dynamic Programming & Recursion

The main DP sheet — state design, the pattern catalogue, and one canonical template per must-know DP family; the worked-solution archive, the rare techniques, and the five heaviest sub-topics live in their own sheets and are linked from here.

drill 11/30 ok · 14 again · next: LC 91, LC 139, LC 300

Strings

Priority 5 of 5 — Must know — expect it in almost every loop

Arrays & Strings

The everyday string catalogue — character-level two-pointer scans, frequency and anagram signatures, run-length grouping, tokenising, parsing and in-place rewriting — while the worked-solution archive, the language-level string API, palindromes, substring search and two-sequence DP each live in their own sheet.

drill 3/13 ok · 3 again · next: LC 696, LC 388, LC 71

Stack

Priority 5 of 5 — Must know — expect it in almost every loop

Hashing, Stacks & Queues

LIFO fundamentals and the canonical stack templates: bracket matching, min-stack, the short monotonic-stack form, explicit-stack traversal and the scope/context ledger.

drill 2/12 ok · 5 again · next: LC 155, LC 232, LC 636

Linked List

Priority 5 of 5 — Must know — expect it in almost every loop

Linked Lists

Pointer surgery on singly and doubly linked lists — reversal, merging, reordering, dummy-head technique, and cycle handling.

drill 4/23 ok · 10 again · next: LC 206, LC 19, LC 143

BST (Binary Search Tree)

Priority 5 of 5 — Must know — expect it in almost every loop

Trees & Heaps

Ordered trees only — what the left < root < right invariant buys you (O(log n) search, sorted inorder, range pruning, order statistics).

drill 4/12 ok · 5 again · next: LC 230, LC 450, LC 669

Tree — Concepts & Patterns

Priority 5 of 5 — Must know — expect it in almost every loop

Trees & Heaps

Tree concepts, tree types and traversal-order strategy — the why and which, plus the advanced techniques that are worked here (Morris threading, binary lifting, and re-rooting DP, the home of LC 834). The per-pattern binary-tree templates live in tree2.md.

drill 4/10 ok · 2 again · next: LC 297, LC 99, LC 114

Tree LCA, Distance & Path Problems

Priority 5 of 5 — Must know — expect it in almost every loop

Trees & Heaps

Lowest common ancestor, node-to-node distance, parent-map (bidirectional) traversal and the root-to-leaf path templates — every tree problem whose answer is a path or a meeting point rather than a shape.

drill 8/14 ok · 5 again · next: LC 124, LC 437, LC 1644

Graph Algorithms

Priority 5 of 5 — Must know — expect it in almost every loop

Graphs

Graph representation, traversal, connectivity, cycle detection and the general graph-problem catalogue.

drill 9/18 ok · 3 again · next: LC 269, LC 785, LC 721

Binary Search on the Answer

Priority 5 of 5 — Must know — expect it in almost every loop

Search & Sort

Binary searching a range of candidate answers against a monotone feasibility predicate — the canFinish / isValid framing, the minimise-maximum vs maximise-minimum decision, the [max(nums), sum(nums)] boundary recipe, and counting predicates over a value domain.

drill 3/14 ok · 5 again · next: LC 1552, LC 378, LC 2616

0/1 背包 DP(中文)

Priority 5 of 5 — Must know — expect it in almost every loop

Dynamic Programming & Recursion

用中文把 0/1 背包從「物品重量價值」一路講到 LC 494/416 的解題流程,重點放在 state 怎麼定義、「拿或不拿」的轉移、以及為什麼內層 loop 一定要倒序;完全背包(Unbounded)與排列/組合的 loop 順序規則不在這裡展開。

Backtracking

Priority 5 of 5 — Must know — expect it in almost every loop

Dynamic Programming & Recursion

Systematic search with undo: the choose/explore/un-choose skeleton, start_idx control, duplicate skipping, pruning, and exactly one canonical template per must-know shape — the long tail of worked solutions and the hard-tier state-carrying templates live in its two satellites.

drill 4/23 ok · 5 again · next: LC 39, LC 17, LC 131

Knapsack DP

Priority 5 of 5 — Must know — expect it in almost every loop

Dynamic Programming & Recursion

The knapsack family in full: 0/1 vs unbounded vs bounded vs group, the subset-sum reduction, why the 0/1 inner loop runs backward, and the loop-order rule that separates combinations from permutations.

drill 2/13 ok · 6 again · next: LC 322, LC 416, LC 279

Python Operation Complexity

Priority 5 of 5 — Must know — expect it in almost every loop

Language Toolkit

What every Python built-in and container operation actually costs, and why: the per-call tables for the built-in functions, list, str, dict/set, tuple, deque, heapq, bisect and int, the CPython layout each cost follows from, and the seven idioms that quietly turn an O(n) solution into an O(n²) one.

Priority 4 of 5 — High value — a gap here costs you roundsHigh value55 sheets

Common enough that a gap here costs you rounds.

Array — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Arrays & Strings

The problems behind array.md's own templates (index as hash, the one-pass running state), each filed under the card it reduces to; an array-tagged problem whose home is another sheet is a one-row pointer here.

Matrix — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Arrays & Strings

The worked-solution archive behind matrix.md: seventeen problems grouped by the geometry or technique each one turns on — traversal order, in-place transformation, staircase search, grid search, 2D DP, and row-pair compression.

Matrix / 2D Grid

Priority 4 of 5 — High value — a gap here costs you rounds

Arrays & Strings

The 2D grid as its own topic — traversal geometry (spiral, diagonal, rotate, transpose), in-place marking, and index↔coordinate arithmetic.

N Sum (2Sum → kSum)

Priority 4 of 5 — High value — a gap here costs you rounds

Arrays & Strings

The k-sum family specifically — 2Sum through kSum, the sort-then-converge recursion, and duplicate handling.

Palindrome

Priority 4 of 5 — High value — a gap here costs you rounds

Arrays & Strings

The palindrome family — expand-from-center, two-pointer verification, palindromic DP, and Manacher — and how to tell which a problem needs.

Prefix Sum

Priority 4 of 5 — High value — a gap here costs you rounds

Arrays & Strings

Prefix / running sums — subarray sums, 2D prefix sums, prefix + hashmap counting.

Prefix Sum — Advanced Templates

Priority 4 of 5 — High value — a gap here costs you rounds

Arrays & Strings

The six prefix-sum templates that borrow another structure or another identity: the complement trick, the monotonic deque for arrays with negatives, row-pair compression for 2D, prefix XOR, the sparse difference array via a hash map, and the prefix-sum-on-a-tree counting map.

Sliding Window — Advanced Window Shapes

Priority 4 of 5 — High value — a gap here costs you rounds

Arrays & Strings

The sliding-window techniques a first pass should skip: the at-most-K-distinct family, exactly-K counting with a forbidden-element reset or in one pass, several non-overlapping windows at once, and windows whose key is a word rather than a character; the seven must-know templates stay in the main sheet, and the advanced shapes another sheet owns (deque extrema, complement windows, value buckets) are pointers here.

Sliding Window — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Arrays & Strings

The worked sliding-window LeetCode problems that are not a template's anchor, one problem card each, filed under the template in the main sheet it reduces to; the templates, the concepts and the decision tables stay in the main sliding-window sheet.

String Algorithms — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Arrays & Strings

The worked string LeetCode problems that are not a template's anchor, each filed as a problem card under the string.md template it reduces to; the concepts, the pattern cards and the anchor problems themselves stay in the main string sheet.

Two Pointers — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Arrays & Strings

The worked two-pointer LeetCode catalogue, one canonical solution per problem, grouped by the template in the main two-pointer sheet that it reduces to; the concepts, pointer types and templates themselves stay in the main two-pointer sheet.

Hash Map — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Hashing, Stacks & Queues

The hash-map family's classic LC problems as problem cards, filed under the hash_map.md template each one reduces to; it has no templates of its own.

Java Collections — Which to Use

Priority 4 of 5 — High value — a gap here costs you rounds

Hashing, Stacks & Queues

Cross-collection chooser — which Java / Python container for which job, and the API gotchas of each.

Monotonic Stack

Priority 4 of 5 — High value — a gap here costs you rounds

Hashing, Stacks & Queues

Next greater / previous smaller / span / histogram problems — the stack stays sorted so each element is pushed and popped once.

Queue Data Structure

Priority 4 of 5 — High value — a gap here costs you rounds

Hashing, Stacks & Queues

FIFO fundamentals — BFS queues, deques, circular buffers, queue-backed designs.

Stack — Expression Parsing

Priority 4 of 5 — High value — a gap here costs you rounds

Hashing, Stacks & Queues

The stack-based expression family: the calculators (LC 224 / 227 / 772), decode-string style nesting (LC 394) and postfix / sequential-operand evaluation (LC 150, 682), with the pre_op delay-insert trick that makes operator precedence fall out of a plain stack.

Stack — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Hashing, Stacks & Queues

The problem set behind stack.md: the stack problems that are not a template's anchor, each as a problem card under the template it reduces to; the monotonic problems are worked in monotonic_stack.md and only pointed to here.

Linked List — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Linked Lists

The problem set behind linked_list.md: each problem filed under the core template it reduces to, as a problem card that names the one step it adds; the templates themselves, and their anchor problems, live in the core sheet.

Two Pointers — Linked List

Priority 4 of 5 — High value — a gap here costs you rounds

Linked Lists

Two pointers over linked-list nodes — fast/slow cycle detection, middle finding, k-th from end, and offset pointers. No array indexing.

Advanced Heap Techniques

Priority 4 of 5 — High value — a gap here costs you rounds

Trees & Heaps

The heap patterns a first pass should skip: lazy deletion, sweep-line "alive" heaps, regret greedy, resource-pool allocators, grid best-first search, and the structures beyond a plain binary heap; the six must-know templates stay in the parent sheet.

BST — Advanced Patterns & Deep Dives

Priority 4 of 5 — High value — a gap here costs you rounds

Trees & Heaps

The BST material a first pass should skip: the lazy O(h)-space iterator, in-order drop detection for a corrupted BST, order-statistic (rank) queries, and the construction variants beyond a sorted array — each with when the simpler bst.md card is enough.

BST — Worked LeetCode Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Trees & Heaps

The BST problems that add one step to a template in bst.md, each worked once as a problem card and filed under the card it reduces to; problems a template or an advanced card already works are listed here as pointers, not re-solved.

Heap — Worked LC Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Trees & Heaps

The problem set for the heap / priority-queue family: each problem filed under the heap.md template it reduces to, with the one step it adds; the templates themselves, and the problems that need an advanced technique, live in the sibling sheets.

Tree Construction

Priority 4 of 5 — High value — a gap here costs you rounds

Trees & Heaps

Building a binary tree from something flat: two traversal arrays, an index range over one array, or a parenthesised / infix string — the inverse direction of every tree problem that only reads a tree.

Tree Pattern Templates

Priority 4 of 5 — High value — a gap here costs you rounds

Trees & Heaps

An index from every tree pattern to the one card that teaches it, plus the traversal forms no core sheet spells out: iterative pre- and post-order, zigzag levels, the bottom-left value and vertical order.

drill 0/8 ok · next: LC 144, LC 145, LC 103

Tree Serialization & String Codec

Priority 4 of 5 — High value — a gap here costs you rounds

Trees & Heaps

Turning a tree into a string and back — subtree fingerprints for identity and duplicate detection, and the full encode/decode codec family (parenthesis, comma plus null marker, depth prefix).

Trie

Priority 4 of 5 — High value — a gap here costs you rounds

Trees & Heaps

The prefix tree — insert/search/startsWith, node layout choices, and the problems where sharing prefixes is the whole trick (autocomplete, word search, XOR trie).

Dijkstra — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Graphs

The worked-solution archive behind Dijkstra.md: eleven problems in both languages, grouped by the shape of the search state, since that is what decides whether you need dist[], a second state dimension, or a plain visited[].

Dijkstra’s Algorithm

Priority 4 of 5 — High value — a gap here costs you rounds

Graphs

Single-source shortest path with non-negative weights, via a priority queue.

Topological Sort

Priority 4 of 5 — High value — a gap here costs you rounds

Graphs

Ordering a DAG — Kahn's BFS, DFS post-order, cycle detection, and the scheduling problems built on them.

Topological Sorting — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Graphs

The problem set behind topology_sorting.md: one problem card per problem, grouped under the template each one reduces to, with no template or theory material of its own.

Union Find (Disjoint Set)

Priority 4 of 5 — High value — a gap here costs you rounds

Graphs

Disjoint set union — connectivity, component counting, cycle detection in undirected graphs, with path compression and union by rank.

Binary Search — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Search & Sort

The problem set for binary_search.md: each problem filed under the index-space template it reduces to, as one problem card with one canonical solution, plus the few answer-space problems that are not worked on binary_search_on_answer.md.

Patience Sorting (LIS)

Priority 4 of 5 — High value — a gap here costs you rounds

Search & Sort

The card-game algorithm behind O(N log N) longest increasing subsequence: the piles, the tails array they collapse to, recovering the subsequence itself, and the problem family that reduces to it.

Quickselect (Kth Element by Partition)

Priority 4 of 5 — High value — a gap here costs you rounds

Search & Sort

Partition-based selection: finding the kth largest, kth smallest or k closest element in O(n) average time by keeping only one side of a quicksort partition, with the partition schemes it can use and the median-of-medians pivot that makes the worst case linear. It owns LC 215's quickselect answer; the heap answer is in heap.md.

drill 3/9 ok · 1 again · next: LC 347, LC 1985, LC 1337

Sorting Algorithms

Priority 4 of 5 — High value — a gap here costs you rounds

Search & Sort

Sorting algorithms and sort-adjacent techniques — comparison sorts and their stability, counting/bucket/radix, quickselect, custom comparators, and cyclic sort.

Advanced Backtracking

Priority 4 of 5 — High value — a gap here costs you rounds

Dynamic Programming & Recursion

Hard-tier backtracking that carries extra state through the recursion — a Trie node, the previous operand, a deletion budget — plus constraint propagation, memoised search and the generic partitioning templates a first pass should skip; none of the must-know shapes are repeated here.

Advanced DP Techniques

Priority 4 of 5 — High value — a gap here costs you rounds

Dynamic Programming & Recursion

The DP appendix — techniques a first pass should skip: game-theory / minimax DP, tree and re-rooting DP, interval and string DP deep dives, probability and step-indexed counting DP, monotonic-queue and stack-carried DP, and the long-form derivations trimmed out of the main sheet.

DP Loop Order & Dependency

Priority 4 of 5 — High value — a gap here costs you rounds

Dynamic Programming & Recursion

Why a bottom-up DP's loop nesting and direction are forced by its own transition, the four ways a wrong order fails, and LC 139 Word Break worked in five orders — including the one that looks right, passes "leetcode", and silently fails the problem's own Example 2.

DP Patterns — One-Screen Templates

Priority 4 of 5 — High value — a gap here costs you rounds

Dynamic Programming & Recursion

Template index — one short section per classic DP pattern (Kadane, LIS, MCM, LCS, knapsack, state machine, grid, bitmask, digit, tree DP, regex, interval scheduling, split, memoised DAG).

Recursion

Priority 4 of 5 — High value — a gap here costs you rounds

Dynamic Programming & Recursion

Recursion as a mechanism — base case, state passed down vs returned up, call-stack cost, and converting to iteration. The pattern families that use recursion each have their own file.

Recursion → DP

Priority 4 of 5 — High value — a gap here costs you rounds

Dynamic Programming & Recursion

The mechanical pipeline: recursion → memoisation → tabulation → space-optimised, applied to one problem at a time.

String DP

Priority 4 of 5 — High value — a gap here costs you rounds

Dynamic Programming & Recursion

DP over one or two strings: the dp[m+1][n+1] two-sequence grid, prefix-based (1-indexed) table design, and the worked patterns for LCS, edit distance, interleaving and wildcard/parenthesis matching.

Greedy Algorithms

Priority 4 of 5 — High value — a gap here costs you rounds

Greedy & Intervals

Taking the locally best choice and the exchange argument that proves it safe — interval scheduling, jump games, task assignment — plus how to spot when greedy fails and DP is required.

Intervals

Priority 4 of 5 — High value — a gap here costs you rounds

Greedy & Intervals

Sort-then-merge interval problems — merge, insert, count overlaps, minimum removals.

Design — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

Design & Simulation

The worked "design a X" problems behind design.md, one problem card each, filed under the structure pair (design.md's patterns) that each one forces.

Design (LC "Design a X")

Priority 4 of 5 — High value — a gap here costs you rounds

Design & Simulation

LC "design a X" problems — reading the required operations off the problem and picking the structure combination that makes every one of them O(1) or O(log n); the worked designs themselves live in the examples sheet.

OOD / Low-Level Design

Priority 4 of 5 — High value — a gap here costs you rounds

Design & Simulation

The low-level-design round — class modelling, SOLID, and the design patterns interviewers actually ask for (strategy, observer, factory, state), with worked designs.

Java Collections & Arrays

Priority 4 of 5 — High value — a gap here costs you rounds

Language Toolkit

The Java library APIs for holding data: arrays and 2D arrays, lists, maps, queues, heaps, stacks and pairs — how to initialise, copy, iterate and index each one, and the traps in doing so.

Java Strings & Sorting

Priority 4 of 5 — High value — a gap here costs you rounds

Language Toolkit

Java String and StringBuilder work — converting to and from char[], slicing, parsing, building and mutating — together with everything comparator-shaped: array, collection and map sorting, and the return-value rules that decide the order.

Java Tricks & Idioms

Priority 4 of 5 — High value — a gap here costs you rounds

Language Toolkit

The Java language semantics that decide whether a correct algorithm produces a correct answer: characters as integers, value vs reference, and integer arithmetic. The library APIs live in two companion sheets.

Python Insertion, Slicing & Index Arithmetic

Priority 4 of 5 — High value — a gap here costs you rounds

Language Toolkit

The two things that produce most wrong answers in Python solutions that are otherwise correct: where an insertion actually lands, and whether an index range means a count or a distance.

Python Standard Library

Priority 4 of 5 — High value — a gap here costs you rounds

Language Toolkit

The library-by-library reference: heapq, sortedcontainers, the built-in sort (sorted / list.sort), bisect, collections, itertools, functools and datetime — the calls, their complexity, and the idiom each one exists to replace.

Python Tricks & Idioms

Priority 4 of 5 — High value — a gap here costs you rounds

Language Toolkit

The Python language idioms that come up while solving problems — copying, string handling, sort keys, integer arithmetic, comprehensions and scope — grouped by what you are trying to do. The standard library, the index arithmetic and the cost of each operation have their own sheets.

Time & Space Complexity

Priority 4 of 5 — High value — a gap here costs you rounds

Interview Meta

Walkthroughs — how to argue the complexity of an actual LC solution, one classic per technique.

Priority 3 of 5 — Worth knowing — usually a variant of a must-know patternWorth knowing42 sheets

Appears regularly, usually as a variant of a tier-5 pattern.

Addition (Strings, Ints, Lists)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Arrays & Strings

Digit-by-digit addition across the four input shapes an interviewer will hand you: strings, integers, arrays, and linked lists.

Difference Array

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Arrays & Strings

O(1) range update, O(n) rebuild — the inverse of a prefix sum.

Prefix Sum — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Arrays & Strings

The worked-solution archive behind prefix_sum.md: the eight problems the templates do not already solve end to end, grouped by which prefix-sum shape they need.

String Matching (KMP, Rolling Hash)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Arrays & Strings

Substring search only — KMP's failure function, Rabin-Karp rolling hash, and the built-in-indexOf-vs-KMP-vs-hash decision.

String Operations & Language APIs

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Arrays & Strings

The language mechanics of strings: Python slicing and methods, Java String and StringBuilder, character classification and case conversion, char arithmetic, the split/join traps and the build-performance rules — not the algorithms that use them.

Hashing & Counting

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Hashing, Stacks & Queues

Hashing internals and counting idioms — hash design, collisions, frequency maps, rolling hash, custom keys.

Monotonic Queue (Deque)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Hashing, Stacks & Queues

Sliding-window max/min in O(1) amortised, using a deque that stays monotonic.

Set

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Hashing, Stacks & Queues

Membership, dedup and set algebra — problems where you only need presence, not an associated value.

Set — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Hashing, Stacks & Queues

The worked-solution archive behind set.md: fourteen problems grouped by what the set is being used for — a memory of what has been seen, set algebra, an O(1) index that replaces a scan, or a component inside a larger algorithm.

Heap Language APIs (heapq / PriorityQueue)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Trees & Heaps

The language mechanics of heaps: every heapq and PriorityQueue call you need, how to fake a max-heap, how to peek without popping, and the traps that come with a partially-ordered container; the algorithms that use them live in the heap sheets.

Tree — Worked LeetCode Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Trees & Heaps

The binary-tree problem set for the templates in binary_tree.md: each problem is filed under the template it reduces to, with the one step it adds, and the templates themselves are not restated here.

Tree Backtracking (Root→Leaf Paths)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Trees & Heaps

The choose / explore / undo skeleton behind tree path problems and the path state each one carries, with the variants the root-to-leaf cards do not cover: the path to one node (LC 236), implicit trees (LC 386, LC 388); the root-to-leaf cards themselves live in tree_lca_distance.md.

Trie — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Trees & Heaps

The worked-solution archive behind trie.md: five problems, from building the structure to the grid search where a trie turns "once per word" into one walk.

Advanced Graph Algorithms

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Graphs

The graph techniques a first interview pass should skip: Tarjan's low-link family (strongly connected components, bridges, articulation points), Euler paths and circuits, and the bipartite extras — parity Union-Find, maximum matching (and the max-flow view of it) and greedy k-colouring.

BFS — Advanced Variants

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Graphs

The BFS techniques a first pass should skip: bidirectional BFS, 0-1 BFS with a deque, multi-source beyond the canonical template, BFS over implicit or augmented state spaces, and all-shortest-path DAG enumeration — the must-know queue templates stay in the main sheet.

BFS — Worked LeetCode Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Graphs

The BFS problem set: one problem card per classic level-order, multi-source, state-space and tree-as-graph problem, each filed under the bfs.md template it reduces to — it teaches no templates of its own.

DFS — Advanced Patterns

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Graphs

The rare DFS tricks a first pass should skip: two-grid validation, edge-direction tracking, cross-component pair counting, trie-backed wildcard search, post-order distance buckets and N-ary rollups, and trees that arrive encoded as indentation or a parent[] array. Graph theory proper (Tarjan, Euler paths) is in graph_advanced.md.

DFS — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Graphs

The problem set for dfs.md: the DFS problems its templates solve, each as one problem card filed under the template it reduces to, plus pointers to the sheet that works a problem when it lives elsewhere.

Graph Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Graphs

The problem set for graph.md: one problem card per problem, grouped under the graph.md template each one reduces to, with no template or theory material of its own.

Minimum Spanning Tree (MST)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Graphs

Minimum spanning trees on undirected weighted graphs: the cut property, Kruskal (sorted edges + Union-Find) and Prim (heap or dense array), each traced step by step with its variants, and the problem shapes built on them — complete geometric graphs, a virtual source node, critical edges and bottleneck trees.

Shortest Path — Which Algorithm?

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Graphs

Decision doc only, and the one home of the shortest-path comparison — which shortest-path algorithm for which problem shape, and where the naive choice is wrong; Dijkstra.md, Bellman-Ford.md and Floyd-Warshall.md point here instead of keeping their own comparison tables. No full implementations.

Topological Sort vs Union Find

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Graphs

Decision doc only — topological sort vs union-find: what each answers, where the naive choice is wrong, and problems solvable by both.

Union Find — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Graphs

The worked-solution archive behind union_find.md: seventeen problems grouped by what a node represents — a vertex, a grid cell, or a variable carrying a ratio — since that is the only thing that changes between them.

Divide & Conquer (Advanced)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Search & Sort

Divide-and-conquer beyond merge sort — the recursion-with-merge shapes (count-while-sorting, closest pair, matrix D&C, D&C on expressions) and their recurrences.

Backtracking — Worked LC Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Dynamic Programming & Recursion

The backtracking problems that are not a template's anchor (LC 17, 784, 996, 93, 140, 980, 22), each as a problem card filed under the backtrack.md template it reduces to; the anchors themselves are worked on their cards there, and this sheet teaches no templates of its own.

Bitmask DP

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Dynamic Programming & Recursion

DP where the state is a subset encoded in an integer: mask operations, submask enumeration, TSP and assignment templates, and the n <= 20 sizing rule.

DP Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Dynamic Programming & Recursion

The classic DP problems that are not a template's anchor (LC 343, 91, 62, 279, 276, 1137), each as a problem card filed under the dp.md template it reduces to, plus an index of where every other common DP problem is worked; no templates or theory of its own.

Kadane's Algorithm

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Dynamic Programming & Recursion

The maximum-subarray family in depth — Kadane and its variants (product, circular, with deletion, 2D).

Monotonic Stack + DP

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Dynamic Programming & Recursion

Problems where a monotonic stack carries a DP value: "how many rounds does this element survive", largest-rectangle-style area DP, and the maximal-square / count-squares grid recurrences.

Stock Trading (State Machine DP)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Dynamic Programming & Recursion

The LC 121/122/123/188/309/714 buy-and-sell family, unified under one dp[i][k][hold] state machine.

Greedy — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Greedy & Intervals

The worked-solution archive behind greedy.md: fourteen problems grouped by the shape of the greedy choice — extend a reach, accumulate and reset, interleave by frequency, sort and take, or commit while scanning.

Sweep Line

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Greedy & Intervals

Line sweep — turn each interval into +1 / -1 events, sort by coordinate, sweep once.

Sweep Line — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Greedy & Intervals

The worked-solution archive behind scanning_line.md: six problems grouped by what the sweep is actually counting — overlap depth, a weighted sum, a heap of live jobs, or the intersection of two sorted lists.

Binary Indexed Tree (Fenwick)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Range Queries & Advanced Structures

The Fenwick tree specifically — i & -i index arithmetic, point update + prefix query, and the problems it is the tidiest answer to.

Segment Tree

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Range Queries & Advanced Structures

Range query + range update structures — the segment tree, lazy propagation, and the BIT-vs-segment-tree-vs-merge-sort decision.

Bit Manipulation

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Math & Bits

How integers are represented in bits (two's complement, fixed width, shifts) and the operations and tricks built on that — masks, XOR identities, lowest set bit, subset enumeration, and bitmask DP.

Bit Manipulation — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Math & Bits

The worked-solution archive behind bit_manipulation.md: nineteen problems grouped by which property of the bit operators they lean on — XOR cancelling pairs, clearing the lowest set bit, carry-free arithmetic, an integer standing in for a subset, or a hand-built mask editing a bit field.

Math

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Math & Bits

Numeric manipulation in interviews — digit extraction, overflow-safe arithmetic, base conversion, roots, and pow. Formula-level counting lives next door.

Iterator

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Design & Simulation

The iterator contract — hasNext/next with lazy state, flattening, peeking, and merging — one idea, in isolation.

System Design Coding Patterns

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Design & Simulation

The distributed-systems patterns that get asked as coding questions — consistent hashing, token-bucket and leaky-bucket rate limiting, and the load-balancing algorithms — with runnable implementations and the trade-offs an interviewer follows up on.

Python Gotchas

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Language Toolkit

Python behaviours that silently cost you a passing submission — mutable defaults, closure late-binding, integer caching, copy semantics — plus the GIL and Python's concurrency story.

Complexity Drills

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Interview Meta

20 self-test drills — read the snippet, state the complexity, check yourself.

Priority 2 of 5 — Niche — read once, revisit only if a company is known to askNiche16 sheets

Rare in interviews — read once, revisit only if a target company is known to ask.

Advanced String Algorithms

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Arrays & Strings

Heavier string machinery — suffix structures, Z-algorithm, Manacher, and string-DP — the parts too specialised for the main string doc.

Priority Queue → see Heap

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Trees & Heaps

Redirect only. This file has been merged into heap.md; it exists to point old links at the right sections.

redirect

Bellman-Ford Algorithm

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Graphs

Single-source shortest path that tolerates negative weights, and detects negative cycles. Also the k-hop-bounded variant.

Floyd-Warshall Algorithm

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Graphs

All-pairs shortest path by DP over intermediate vertices — O(V³), dense graphs, transitive closure.

QuickSelect → see Quickselect

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Search & Sort

Redirect only. This sheet was renamed to quickselect.md in Nov 2026; it exists to point old links at the right sections.

redirect

Digit DP

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Dynamic Programming & Recursion

Counting how many numbers in a range satisfy a digit-level property: the tight/started/position state, the universal top-down template, and the count(R) - count(L-1) range trick.

Interval Overlap → see Interval Overlap Predicate

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Greedy & Intervals

Redirect only. This sheet was renamed to array_overlap_explanation.md in Nov 2026 to fix the misspelt filename; it exists to point old links at the right sections.

redirect

Interval Overlap Predicate

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Greedy & Intervals

One idea only — the interval-overlap predicate: closed [a,b] vs half-open [a,b), and which one each LC problem needs.

Algorithms Under a Memory Cap

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Range Queries & Advanced Structures

What to do when the input does not fit in RAM: bit vectors, bucket-then-refine passes, sharding a file by hash, and external merge sort — the techniques that still return an exact answer by paying with extra passes.

Streaming Algorithms

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Range Queries & Advanced Structures

Algorithms constrained to one pass and sub-linear memory — reservoir sampling, Boyer-Moore majority, weighted random pick, and approximate counting.

Combinatorics & Number Theory

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Math & Bits

Counting and number theory as they appear in interviews — modular arithmetic, GCD/LCM, sieves, nCr, reservoir sampling, and basic geometry.

Math & Logic Puzzles

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Math & Bits

The four moves that solve brainteaser-style questions: counting how much information one test buys, balancing the worst case, finding the invariant, and using linearity of expectation. It teaches the moves, not a riddle list.

Concurrency (Java)

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Design & Simulation

The handful of Java concurrency problems that appear at L4+ — ordered printing, producer/consumer, read-write coordination and deadlock avoidance — plus the primitives they need.

Simulation

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Design & Simulation

Problems where the answer is the faithful step-by-step execution — state machines, robot/grid walks, game rounds, iterative rewriting — plus how to keep such code shrinkable.

Coding Interview Process

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Interview Meta

Redirect. The six-step interview loop moved into lc_pattern.md, which is the page you actually open when starting a problem.

redirect

LC Category Index (wisdompeak)

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Interview Meta

A pointer to the wisdompeak problem taxonomy, and a map from its 29 categories to the cheatsheet in this repo that teaches each one. The taxonomy itself is not mirrored here.

redirect

By topic

Arrays & Strings21 sheets

The highest-frequency surface in any interview loop. Master the four pattern families here before anything else.

Array

Priority 5 of 5 — Must know — expect it in almost every loop

Array fundamentals — in-place rewriting, rotation, partitioning, and the index-as-hash trick. Owns the operations; the pattern families (windows, pointers, prefix sums) each have their own file.

drill 4/15 ok · 3 again · next: LC 88, LC 2657, LC 41

Sliding Window

Priority 5 of 5 — Must know — expect it in almost every loop

Windows that grow and shrink on a condition — fixed-size, variable-size, at-most-k, and exactly-k by subtraction; owns the expand/contract loop and the seven canonical window templates.

drill 5/14 ok · 4 again · next: LC 438, LC 4067, LC 992

Strings

Priority 5 of 5 — Must know — expect it in almost every loop

The everyday string catalogue — character-level two-pointer scans, frequency and anagram signatures, run-length grouping, tokenising, parsing and in-place rewriting — while the worked-solution archive, the language-level string API, palindromes, substring search and two-sequence DP each live in their own sheet.

drill 3/13 ok · 3 again · next: LC 696, LC 388, LC 71

Two Pointers

Priority 5 of 5 — Must know — expect it in almost every loop

The two-pointer family on arrays and strings — opposite-ends convergence, fast/slow, expand-from-centre and the read/write partition, with one canonical template for each; window problems that grow and shrink on a condition live elsewhere.

drill 8/16 ok · 4 again · next: LC 5, LC 647, LC 88

Array — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The problems behind array.md's own templates (index as hash, the one-pass running state), each filed under the card it reduces to; an array-tagged problem whose home is another sheet is a one-row pointer here.

Matrix — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The worked-solution archive behind matrix.md: seventeen problems grouped by the geometry or technique each one turns on — traversal order, in-place transformation, staircase search, grid search, 2D DP, and row-pair compression.

Matrix / 2D Grid

Priority 4 of 5 — High value — a gap here costs you rounds

The 2D grid as its own topic — traversal geometry (spiral, diagonal, rotate, transpose), in-place marking, and index↔coordinate arithmetic.

N Sum (2Sum → kSum)

Priority 4 of 5 — High value — a gap here costs you rounds

The k-sum family specifically — 2Sum through kSum, the sort-then-converge recursion, and duplicate handling.

Palindrome

Priority 4 of 5 — High value — a gap here costs you rounds

The palindrome family — expand-from-center, two-pointer verification, palindromic DP, and Manacher — and how to tell which a problem needs.

Prefix Sum

Priority 4 of 5 — High value — a gap here costs you rounds

Prefix / running sums — subarray sums, 2D prefix sums, prefix + hashmap counting.

Prefix Sum — Advanced Templates

Priority 4 of 5 — High value — a gap here costs you rounds

The six prefix-sum templates that borrow another structure or another identity: the complement trick, the monotonic deque for arrays with negatives, row-pair compression for 2D, prefix XOR, the sparse difference array via a hash map, and the prefix-sum-on-a-tree counting map.

Sliding Window — Advanced Window Shapes

Priority 4 of 5 — High value — a gap here costs you rounds

The sliding-window techniques a first pass should skip: the at-most-K-distinct family, exactly-K counting with a forbidden-element reset or in one pass, several non-overlapping windows at once, and windows whose key is a word rather than a character; the seven must-know templates stay in the main sheet, and the advanced shapes another sheet owns (deque extrema, complement windows, value buckets) are pointers here.

Sliding Window — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The worked sliding-window LeetCode problems that are not a template's anchor, one problem card each, filed under the template in the main sheet it reduces to; the templates, the concepts and the decision tables stay in the main sliding-window sheet.

String Algorithms — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The worked string LeetCode problems that are not a template's anchor, each filed as a problem card under the string.md template it reduces to; the concepts, the pattern cards and the anchor problems themselves stay in the main string sheet.

Two Pointers — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The worked two-pointer LeetCode catalogue, one canonical solution per problem, grouped by the template in the main two-pointer sheet that it reduces to; the concepts, pointer types and templates themselves stay in the main two-pointer sheet.

Addition (Strings, Ints, Lists)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Digit-by-digit addition across the four input shapes an interviewer will hand you: strings, integers, arrays, and linked lists.

Difference Array

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

O(1) range update, O(n) rebuild — the inverse of a prefix sum.

Prefix Sum — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The worked-solution archive behind prefix_sum.md: the eight problems the templates do not already solve end to end, grouped by which prefix-sum shape they need.

String Matching (KMP, Rolling Hash)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Substring search only — KMP's failure function, Rabin-Karp rolling hash, and the built-in-indexOf-vs-KMP-vs-hash decision.

String Operations & Language APIs

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The language mechanics of strings: Python slicing and methods, Java String and StringBuilder, character classification and case conversion, char arithmetic, the split/join traps and the build-performance rules — not the algorithms that use them.

Advanced String Algorithms

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Heavier string machinery — suffix structures, Z-algorithm, Manacher, and string-DP — the parts too specialised for the main string doc.

Hashing, Stacks & Queues12 sheets

O(1) lookup and LIFO/FIFO discipline — the structures that turn an O(n^2) scan into O(n).

Hash Map

Priority 5 of 5 — Must know — expect it in almost every loop

Key→value problem patterns — lookup, grouping, index maps, prefix-sum maps, remapping.

drill 5/16 ok · 4 again · next: LC 347, LC 146, LC 438

Stack

Priority 5 of 5 — Must know — expect it in almost every loop

LIFO fundamentals and the canonical stack templates: bracket matching, min-stack, the short monotonic-stack form, explicit-stack traversal and the scope/context ledger.

drill 2/12 ok · 5 again · next: LC 155, LC 232, LC 636

Hash Map — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The hash-map family's classic LC problems as problem cards, filed under the hash_map.md template each one reduces to; it has no templates of its own.

Java Collections — Which to Use

Priority 4 of 5 — High value — a gap here costs you rounds

Cross-collection chooser — which Java / Python container for which job, and the API gotchas of each.

Monotonic Stack

Priority 4 of 5 — High value — a gap here costs you rounds

Next greater / previous smaller / span / histogram problems — the stack stays sorted so each element is pushed and popped once.

Queue Data Structure

Priority 4 of 5 — High value — a gap here costs you rounds

FIFO fundamentals — BFS queues, deques, circular buffers, queue-backed designs.

Stack — Expression Parsing

Priority 4 of 5 — High value — a gap here costs you rounds

The stack-based expression family: the calculators (LC 224 / 227 / 772), decode-string style nesting (LC 394) and postfix / sequential-operand evaluation (LC 150, 682), with the pre_op delay-insert trick that makes operator precedence fall out of a plain stack.

Stack — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The problem set behind stack.md: the stack problems that are not a template's anchor, each as a problem card under the template it reduces to; the monotonic problems are worked in monotonic_stack.md and only pointed to here.

Hashing & Counting

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Hashing internals and counting idioms — hash design, collisions, frequency maps, rolling hash, custom keys.

Monotonic Queue (Deque)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Sliding-window max/min in O(1) amortised, using a deque that stays monotonic.

Set

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Membership, dedup and set algebra — problems where you only need presence, not an associated value.

Set — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The worked-solution archive behind set.md: fourteen problems grouped by what the set is being used for — a memory of what has been seen, set algebra, an O(1) index that replaces a scan, or a component inside a larger algorithm.

Linked Lists3 sheets

Pointer surgery. Low conceptual depth, high implementation-precision bar.

Linked List

Priority 5 of 5 — Must know — expect it in almost every loop

Pointer surgery on singly and doubly linked lists — reversal, merging, reordering, dummy-head technique, and cycle handling.

drill 4/23 ok · 10 again · next: LC 206, LC 19, LC 143

Linked List — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The problem set behind linked_list.md: each problem filed under the core template it reduces to, as a problem card that names the one step it adds; the templates themselves, and their anchor problems, live in the core sheet.

Two Pointers — Linked List

Priority 4 of 5 — High value — a gap here costs you rounds

Two pointers over linked-list nodes — fast/slow cycle detection, middle finding, k-th from end, and offset pointers. No array indexing.

Trees & Heaps18 sheets

Recursive structure plus ordered access. Roughly a quarter of all tree/heap-tagged interview questions come from these five sheets.

Binary Tree

Priority 5 of 5 — Must know — expect it in almost every loop

Binary-tree-specific reasoning: which direction DFS state flows (down vs up), plus the 11 structural templates built on that.

drill 13/20 ok · 5 again · next: LC 572, LC 222, LC 652

BST (Binary Search Tree)

Priority 5 of 5 — Must know — expect it in almost every loop

Ordered trees only — what the left < root < right invariant buys you (O(log n) search, sorted inorder, range pruning, order statistics).

drill 4/12 ok · 5 again · next: LC 230, LC 450, LC 669

Heap & Priority Queue

Priority 5 of 5 — Must know — expect it in almost every loop

Both the heap (the structure) and the priority queue (the ADT it implements), in Python and Java. Formerly split across heap.md + priority_queue.md, which solved the same problems twice.

drill 5/18 ok · 6 again · next: LC 347, LC 23, LC 703

Tree — Concepts & Patterns

Priority 5 of 5 — Must know — expect it in almost every loop

Tree concepts, tree types and traversal-order strategy — the why and which, plus the advanced techniques that are worked here (Morris threading, binary lifting, and re-rooting DP, the home of LC 834). The per-pattern binary-tree templates live in tree2.md.

drill 4/10 ok · 2 again · next: LC 297, LC 99, LC 114

Tree LCA, Distance & Path Problems

Priority 5 of 5 — Must know — expect it in almost every loop

Lowest common ancestor, node-to-node distance, parent-map (bidirectional) traversal and the root-to-leaf path templates — every tree problem whose answer is a path or a meeting point rather than a shape.

drill 8/14 ok · 5 again · next: LC 124, LC 437, LC 1644

Advanced Heap Techniques

Priority 4 of 5 — High value — a gap here costs you rounds

The heap patterns a first pass should skip: lazy deletion, sweep-line "alive" heaps, regret greedy, resource-pool allocators, grid best-first search, and the structures beyond a plain binary heap; the six must-know templates stay in the parent sheet.

BST — Advanced Patterns & Deep Dives

Priority 4 of 5 — High value — a gap here costs you rounds

The BST material a first pass should skip: the lazy O(h)-space iterator, in-order drop detection for a corrupted BST, order-statistic (rank) queries, and the construction variants beyond a sorted array — each with when the simpler bst.md card is enough.

BST — Worked LeetCode Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The BST problems that add one step to a template in bst.md, each worked once as a problem card and filed under the card it reduces to; problems a template or an advanced card already works are listed here as pointers, not re-solved.

Heap — Worked LC Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The problem set for the heap / priority-queue family: each problem filed under the heap.md template it reduces to, with the one step it adds; the templates themselves, and the problems that need an advanced technique, live in the sibling sheets.

Tree Construction

Priority 4 of 5 — High value — a gap here costs you rounds

Building a binary tree from something flat: two traversal arrays, an index range over one array, or a parenthesised / infix string — the inverse direction of every tree problem that only reads a tree.

Tree Pattern Templates

Priority 4 of 5 — High value — a gap here costs you rounds

An index from every tree pattern to the one card that teaches it, plus the traversal forms no core sheet spells out: iterative pre- and post-order, zigzag levels, the bottom-left value and vertical order.

drill 0/8 ok · next: LC 144, LC 145, LC 103

Tree Serialization & String Codec

Priority 4 of 5 — High value — a gap here costs you rounds

Turning a tree into a string and back — subtree fingerprints for identity and duplicate detection, and the full encode/decode codec family (parenthesis, comma plus null marker, depth prefix).

Trie

Priority 4 of 5 — High value — a gap here costs you rounds

The prefix tree — insert/search/startsWith, node layout choices, and the problems where sharing prefixes is the whole trick (autocomplete, word search, XOR trie).

Heap Language APIs (heapq / PriorityQueue)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The language mechanics of heaps: every heapq and PriorityQueue call you need, how to fake a max-heap, how to peek without popping, and the traps that come with a partially-ordered container; the algorithms that use them live in the heap sheets.

Tree — Worked LeetCode Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The binary-tree problem set for the templates in binary_tree.md: each problem is filed under the template it reduces to, with the one step it adds, and the templates themselves are not restated here.

Tree Backtracking (Root→Leaf Paths)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The choose / explore / undo skeleton behind tree path problems and the path state each one carries, with the variants the root-to-leaf cards do not cover: the path to one node (LC 236), implicit trees (LC 386, LC 388); the root-to-leaf cards themselves live in tree_lca_distance.md.

Trie — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The worked-solution archive behind trie.md: five problems, from building the structure to the grid search where a trie turns "once per word" into one walk.

Priority Queue → see Heap

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Redirect only. This file has been merged into heap.md; it exists to point old links at the right sections.

redirect

Graphs20 sheets

Traversal, connectivity and ordering. BFS/DFS are must-know; the weighted shortest-path trio is mostly L5+ territory.

BFS (Breadth-First Search)

Priority 5 of 5 — Must know — expect it in almost every loop

The main BFS reference: the queue templates, level-by-level expansion, grid and multi-source BFS, and why first visit equals shortest path on an unweighted graph; the heavier variants and the long tail of worked problems live in their own sheets.

drill 4/13 ok · 3 again · next: LC 542, LC 785, LC 752

DFS (Depth-First Search)

Priority 5 of 5 — Must know — expect it in almost every loop

The main DFS reference: the ten core depth-first templates — tree traversal, grid flood fill, path finding, backtracking, tree modification, post-order aggregation, boundary elimination, shape signatures and weighted-edge traversal — with the recognition table that picks between them.

drill 9/20 ok · 7 again · next: LC 417, LC 124, LC 101

Graph Algorithms

Priority 5 of 5 — Must know — expect it in almost every loop

Graph representation, traversal, connectivity, cycle detection and the general graph-problem catalogue.

drill 9/18 ok · 3 again · next: LC 269, LC 785, LC 721

Dijkstra — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The worked-solution archive behind Dijkstra.md: eleven problems in both languages, grouped by the shape of the search state, since that is what decides whether you need dist[], a second state dimension, or a plain visited[].

Dijkstra’s Algorithm

Priority 4 of 5 — High value — a gap here costs you rounds

Single-source shortest path with non-negative weights, via a priority queue.

Topological Sort

Priority 4 of 5 — High value — a gap here costs you rounds

Ordering a DAG — Kahn's BFS, DFS post-order, cycle detection, and the scheduling problems built on them.

Topological Sorting — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The problem set behind topology_sorting.md: one problem card per problem, grouped under the template each one reduces to, with no template or theory material of its own.

Union Find (Disjoint Set)

Priority 4 of 5 — High value — a gap here costs you rounds

Disjoint set union — connectivity, component counting, cycle detection in undirected graphs, with path compression and union by rank.

Advanced Graph Algorithms

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The graph techniques a first interview pass should skip: Tarjan's low-link family (strongly connected components, bridges, articulation points), Euler paths and circuits, and the bipartite extras — parity Union-Find, maximum matching (and the max-flow view of it) and greedy k-colouring.

BFS — Advanced Variants

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The BFS techniques a first pass should skip: bidirectional BFS, 0-1 BFS with a deque, multi-source beyond the canonical template, BFS over implicit or augmented state spaces, and all-shortest-path DAG enumeration — the must-know queue templates stay in the main sheet.

BFS — Worked LeetCode Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The BFS problem set: one problem card per classic level-order, multi-source, state-space and tree-as-graph problem, each filed under the bfs.md template it reduces to — it teaches no templates of its own.

DFS — Advanced Patterns

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The rare DFS tricks a first pass should skip: two-grid validation, edge-direction tracking, cross-component pair counting, trie-backed wildcard search, post-order distance buckets and N-ary rollups, and trees that arrive encoded as indentation or a parent[] array. Graph theory proper (Tarjan, Euler paths) is in graph_advanced.md.

DFS — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The problem set for dfs.md: the DFS problems its templates solve, each as one problem card filed under the template it reduces to, plus pointers to the sheet that works a problem when it lives elsewhere.

Graph Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The problem set for graph.md: one problem card per problem, grouped under the graph.md template each one reduces to, with no template or theory material of its own.

Minimum Spanning Tree (MST)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Minimum spanning trees on undirected weighted graphs: the cut property, Kruskal (sorted edges + Union-Find) and Prim (heap or dense array), each traced step by step with its variants, and the problem shapes built on them — complete geometric graphs, a virtual source node, critical edges and bottleneck trees.

Shortest Path — Which Algorithm?

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Decision doc only, and the one home of the shortest-path comparison — which shortest-path algorithm for which problem shape, and where the naive choice is wrong; Dijkstra.md, Bellman-Ford.md and Floyd-Warshall.md point here instead of keeping their own comparison tables. No full implementations.

Topological Sort vs Union Find

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Decision doc only — topological sort vs union-find: what each answers, where the naive choice is wrong, and problems solvable by both.

Union Find — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The worked-solution archive behind union_find.md: seventeen problems grouped by what a node represents — a vertex, a grid cell, or a variable carrying a ratio — since that is the only thing that changes between them.

Bellman-Ford Algorithm

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Single-source shortest path that tolerates negative weights, and detects negative cycles. Also the k-hop-bounded variant.

Floyd-Warshall Algorithm

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

All-pairs shortest path by DP over intermediate vertices — O(V³), dense graphs, transitive closure.

Search & Sort8 sheets

Halving a monotonic space, and what sorting buys you. Binary search on the answer is the single most under-practised tier-5 skill.

Binary Search

Priority 5 of 5 — Must know — expect it in almost every loop

Halving a monotonic search space — the loop-invariant reasoning behind l <= r vs l < r, the boundary (lower/upper bound) templates, rotated arrays, and floating-point and 2D search.

drill 8/20 ok · 4 again · next: LC 300, LC 35, LC 702

Binary Search on the Answer

Priority 5 of 5 — Must know — expect it in almost every loop

Binary searching a range of candidate answers against a monotone feasibility predicate — the canFinish / isValid framing, the minimise-maximum vs maximise-minimum decision, the [max(nums), sum(nums)] boundary recipe, and counting predicates over a value domain.

drill 3/14 ok · 5 again · next: LC 1552, LC 378, LC 2616

Binary Search — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The problem set for binary_search.md: each problem filed under the index-space template it reduces to, as one problem card with one canonical solution, plus the few answer-space problems that are not worked on binary_search_on_answer.md.

Patience Sorting (LIS)

Priority 4 of 5 — High value — a gap here costs you rounds

The card-game algorithm behind O(N log N) longest increasing subsequence: the piles, the tails array they collapse to, recovering the subsequence itself, and the problem family that reduces to it.

Quickselect (Kth Element by Partition)

Priority 4 of 5 — High value — a gap here costs you rounds

Partition-based selection: finding the kth largest, kth smallest or k closest element in O(n) average time by keeping only one side of a quicksort partition, with the partition schemes it can use and the median-of-medians pivot that makes the worst case linear. It owns LC 215's quickselect answer; the heap answer is in heap.md.

drill 3/9 ok · 1 again · next: LC 347, LC 1985, LC 1337

Sorting Algorithms

Priority 4 of 5 — High value — a gap here costs you rounds

Sorting algorithms and sort-adjacent techniques — comparison sorts and their stability, counting/bucket/radix, quickselect, custom comparators, and cyclic sort.

Divide & Conquer (Advanced)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Divide-and-conquer beyond merge sort — the recursion-with-merge shapes (count-while-sorting, closest pair, matrix D&C, D&C on expressions) and their recurrences.

QuickSelect → see Quickselect

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Redirect only. This sheet was renamed to quickselect.md in Nov 2026; it exists to point old links at the right sections.

redirect

Dynamic Programming & Recursion18 sheets

The hardest tier-5 block. Start from recursion, memoise, then tabulate.

0/1 背包 DP(中文)

Priority 5 of 5 — Must know — expect it in almost every loop

用中文把 0/1 背包從「物品重量價值」一路講到 LC 494/416 的解題流程,重點放在 state 怎麼定義、「拿或不拿」的轉移、以及為什麼內層 loop 一定要倒序;完全背包(Unbounded)與排列/組合的 loop 順序規則不在這裡展開。

Backtracking

Priority 5 of 5 — Must know — expect it in almost every loop

Systematic search with undo: the choose/explore/un-choose skeleton, start_idx control, duplicate skipping, pruning, and exactly one canonical template per must-know shape — the long tail of worked solutions and the hard-tier state-carrying templates live in its two satellites.

drill 4/23 ok · 5 again · next: LC 39, LC 17, LC 131

Dynamic Programming (DP)

Priority 5 of 5 — Must know — expect it in almost every loop

The main DP sheet — state design, the pattern catalogue, and one canonical template per must-know DP family; the worked-solution archive, the rare techniques, and the five heaviest sub-topics live in their own sheets and are linked from here.

drill 11/30 ok · 14 again · next: LC 91, LC 139, LC 300

Knapsack DP

Priority 5 of 5 — Must know — expect it in almost every loop

The knapsack family in full: 0/1 vs unbounded vs bounded vs group, the subset-sum reduction, why the 0/1 inner loop runs backward, and the loop-order rule that separates combinations from permutations.

drill 2/13 ok · 6 again · next: LC 322, LC 416, LC 279

Advanced Backtracking

Priority 4 of 5 — High value — a gap here costs you rounds

Hard-tier backtracking that carries extra state through the recursion — a Trie node, the previous operand, a deletion budget — plus constraint propagation, memoised search and the generic partitioning templates a first pass should skip; none of the must-know shapes are repeated here.

Advanced DP Techniques

Priority 4 of 5 — High value — a gap here costs you rounds

The DP appendix — techniques a first pass should skip: game-theory / minimax DP, tree and re-rooting DP, interval and string DP deep dives, probability and step-indexed counting DP, monotonic-queue and stack-carried DP, and the long-form derivations trimmed out of the main sheet.

DP Loop Order & Dependency

Priority 4 of 5 — High value — a gap here costs you rounds

Why a bottom-up DP's loop nesting and direction are forced by its own transition, the four ways a wrong order fails, and LC 139 Word Break worked in five orders — including the one that looks right, passes "leetcode", and silently fails the problem's own Example 2.

DP Patterns — One-Screen Templates

Priority 4 of 5 — High value — a gap here costs you rounds

Template index — one short section per classic DP pattern (Kadane, LIS, MCM, LCS, knapsack, state machine, grid, bitmask, digit, tree DP, regex, interval scheduling, split, memoised DAG).

Recursion

Priority 4 of 5 — High value — a gap here costs you rounds

Recursion as a mechanism — base case, state passed down vs returned up, call-stack cost, and converting to iteration. The pattern families that use recursion each have their own file.

Recursion → DP

Priority 4 of 5 — High value — a gap here costs you rounds

The mechanical pipeline: recursion → memoisation → tabulation → space-optimised, applied to one problem at a time.

String DP

Priority 4 of 5 — High value — a gap here costs you rounds

DP over one or two strings: the dp[m+1][n+1] two-sequence grid, prefix-based (1-indexed) table design, and the worked patterns for LCS, edit distance, interleaving and wildcard/parenthesis matching.

Backtracking — Worked LC Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The backtracking problems that are not a template's anchor (LC 17, 784, 996, 93, 140, 980, 22), each as a problem card filed under the backtrack.md template it reduces to; the anchors themselves are worked on their cards there, and this sheet teaches no templates of its own.

Bitmask DP

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

DP where the state is a subset encoded in an integer: mask operations, submask enumeration, TSP and assignment templates, and the n <= 20 sizing rule.

DP Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The classic DP problems that are not a template's anchor (LC 343, 91, 62, 279, 276, 1137), each as a problem card filed under the dp.md template it reduces to, plus an index of where every other common DP problem is worked; no templates or theory of its own.

Kadane's Algorithm

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The maximum-subarray family in depth — Kadane and its variants (product, circular, with deletion, 2D).

Monotonic Stack + DP

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Problems where a monotonic stack carries a DP value: "how many rounds does this element survive", largest-rectangle-style area DP, and the maximal-square / count-squares grid recurrences.

Stock Trading (State Machine DP)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The LC 121/122/123/188/309/714 buy-and-sell family, unified under one dp[i][k][hold] state machine.

Digit DP

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Counting how many numbers in a range satisfy a digit-level property: the tight/started/position state, the universal top-down template, and the count(R) - count(L-1) range trick.

Greedy & Intervals7 sheets

Sort-then-scan, and the exchange argument that proves it correct.

Greedy Algorithms

Priority 4 of 5 — High value — a gap here costs you rounds

Taking the locally best choice and the exchange argument that proves it safe — interval scheduling, jump games, task assignment — plus how to spot when greedy fails and DP is required.

Intervals

Priority 4 of 5 — High value — a gap here costs you rounds

Sort-then-merge interval problems — merge, insert, count overlaps, minimum removals.

Greedy — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The worked-solution archive behind greedy.md: fourteen problems grouped by the shape of the greedy choice — extend a reach, accumulate and reset, interleave by frequency, sort and take, or commit while scanning.

Sweep Line

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Line sweep — turn each interval into +1 / -1 events, sort by coordinate, sweep once.

Sweep Line — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The worked-solution archive behind scanning_line.md: six problems grouped by what the sweep is actually counting — overlap depth, a weighted sum, a heap of live jobs, or the intersection of two sorted lists.

Interval Overlap → see Interval Overlap Predicate

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Redirect only. This sheet was renamed to array_overlap_explanation.md in Nov 2026 to fix the misspelt filename; it exists to point old links at the right sections.

redirect

Interval Overlap Predicate

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

One idea only — the interval-overlap predicate: closed [a,b] vs half-open [a,b), and which one each LC problem needs.

Range Queries & Advanced Structures4 sheets

Reach for these only when a problem needs updates *and* range queries — otherwise a prefix sum is enough.

Binary Indexed Tree (Fenwick)

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The Fenwick tree specifically — i & -i index arithmetic, point update + prefix query, and the problems it is the tidiest answer to.

Segment Tree

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Range query + range update structures — the segment tree, lazy propagation, and the BIT-vs-segment-tree-vs-merge-sort decision.

Algorithms Under a Memory Cap

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

What to do when the input does not fit in RAM: bit vectors, bucket-then-refine passes, sharding a file by hash, and external merge sort — the techniques that still return an exact answer by paying with extra passes.

Streaming Algorithms

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Algorithms constrained to one pass and sub-linear memory — reservoir sampling, Boyer-Moore majority, weighted random pick, and approximate counting.

Math & Bits5 sheets

Small, self-contained topics. Cheap to learn, occasionally decisive.

Bit Manipulation

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

How integers are represented in bits (two's complement, fixed width, shifts) and the operations and tricks built on that — masks, XOR identities, lowest set bit, subset enumeration, and bitmask DP.

Bit Manipulation — Worked Examples

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The worked-solution archive behind bit_manipulation.md: nineteen problems grouped by which property of the bit operators they lean on — XOR cancelling pairs, clearing the lowest set bit, carry-free arithmetic, an integer standing in for a subset, or a hand-built mask editing a bit field.

Math

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Numeric manipulation in interviews — digit extraction, overflow-safe arithmetic, base conversion, roots, and pow. Formula-level counting lives next door.

Combinatorics & Number Theory

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Counting and number theory as they appear in interviews — modular arithmetic, GCD/LCM, sieves, nCr, reservoir sampling, and basic geometry.

Math & Logic Puzzles

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

The four moves that solve brainteaser-style questions: counting how much information one test buys, balancing the worst case, finding the invariant, and using linearity of expectation. It teaches the moves, not a riddle list.

Design & Simulation7 sheets

"Design a X" and low-level-design rounds — judged on operation complexity and class modelling, not cleverness.

Design — Worked Examples

Priority 4 of 5 — High value — a gap here costs you rounds

The worked "design a X" problems behind design.md, one problem card each, filed under the structure pair (design.md's patterns) that each one forces.

Design (LC "Design a X")

Priority 4 of 5 — High value — a gap here costs you rounds

LC "design a X" problems — reading the required operations off the problem and picking the structure combination that makes every one of them O(1) or O(log n); the worked designs themselves live in the examples sheet.

OOD / Low-Level Design

Priority 4 of 5 — High value — a gap here costs you rounds

The low-level-design round — class modelling, SOLID, and the design patterns interviewers actually ask for (strategy, observer, factory, state), with worked designs.

Iterator

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The iterator contract — hasNext/next with lazy state, flattening, peeking, and merging — one idea, in isolation.

System Design Coding Patterns

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

The distributed-systems patterns that get asked as coding questions — consistent hashing, token-bucket and leaky-bucket rate limiting, and the load-balancing algorithms — with runnable implementations and the trade-offs an interviewer follows up on.

Concurrency (Java)

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

The handful of Java concurrency problems that appear at L4+ — ordered printing, producer/consumer, read-write coordination and deadlock avoidance — plus the primitives they need.

Simulation

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Problems where the answer is the faithful step-by-step execution — state machines, robot/grid walks, game rounds, iterative rewriting — plus how to keep such code shrinkable.

Language Toolkit8 sheets

Language mechanics, not algorithms. Read for speed and to stop losing submissions to avoidable traps.

Python Operation Complexity

Priority 5 of 5 — Must know — expect it in almost every loop

What every Python built-in and container operation actually costs, and why: the per-call tables for the built-in functions, list, str, dict/set, tuple, deque, heapq, bisect and int, the CPython layout each cost follows from, and the seven idioms that quietly turn an O(n) solution into an O(n²) one.

Java Collections & Arrays

Priority 4 of 5 — High value — a gap here costs you rounds

The Java library APIs for holding data: arrays and 2D arrays, lists, maps, queues, heaps, stacks and pairs — how to initialise, copy, iterate and index each one, and the traps in doing so.

Java Strings & Sorting

Priority 4 of 5 — High value — a gap here costs you rounds

Java String and StringBuilder work — converting to and from char[], slicing, parsing, building and mutating — together with everything comparator-shaped: array, collection and map sorting, and the return-value rules that decide the order.

Java Tricks & Idioms

Priority 4 of 5 — High value — a gap here costs you rounds

The Java language semantics that decide whether a correct algorithm produces a correct answer: characters as integers, value vs reference, and integer arithmetic. The library APIs live in two companion sheets.

Python Insertion, Slicing & Index Arithmetic

Priority 4 of 5 — High value — a gap here costs you rounds

The two things that produce most wrong answers in Python solutions that are otherwise correct: where an insertion actually lands, and whether an index range means a count or a distance.

Python Standard Library

Priority 4 of 5 — High value — a gap here costs you rounds

The library-by-library reference: heapq, sortedcontainers, the built-in sort (sorted / list.sort), bisect, collections, itertools, functools and datetime — the calls, their complexity, and the idiom each one exists to replace.

Python Tricks & Idioms

Priority 4 of 5 — High value — a gap here costs you rounds

The Python language idioms that come up while solving problems — copying, string handling, sort keys, integer arithmetic, comprehensions and scope — grouped by what you are trying to do. The standard library, the index arithmetic and the cost of each operation have their own sheets.

Python Gotchas

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

Python behaviours that silently cost you a passing submission — mutable defaults, closure late-binding, integer caching, copy semantics — plus the GIL and Python's concurrency story.

Interview Meta6 sheets

How to triage a question and state its complexity. Read before your first mock.

Complexity Cheat Sheet

Priority 5 of 5 — Must know — expect it in almost every loop

Lookup tables — Big-O of every common data structure and classic algorithm, plus the math intuitions behind them.

LeetCode Pattern Guide

Priority 5 of 5 — Must know — expect it in almost every loop

The front door: from a problem statement to the card that solves it — the signal in the wording, the constraint cue, the pattern, a link to its card, and the look-alike that is not it. A router only: every template lives in the card a row links to.

drill 14/27 ok · 11 again · next: LC 206, LC 322, LC 347

Time & Space Complexity

Priority 4 of 5 — High value — a gap here costs you rounds

Walkthroughs — how to argue the complexity of an actual LC solution, one classic per technique.

Complexity Drills

Priority 3 of 5 — Worth knowing — usually a variant of a must-know pattern

20 self-test drills — read the snippet, state the complexity, check yourself.

Coding Interview Process

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

Redirect. The six-step interview loop moved into lc_pattern.md, which is the page you actually open when starting a problem.

redirect

LC Category Index (wisdompeak)

Priority 2 of 5 — Niche — read once, revisit only if a company is known to ask

A pointer to the wisdompeak problem taxonomy, and a map from its 29 categories to the cheatsheet in this repo that teaches each one. The taxonomy itself is not mirrored here.

redirect

How to use this: pick the sheet, read its Scope line to confirm it owns your problem, then jump straight to the starred sections — the same stars mark the sections inside each sheet that are worth memorising. The drill counts come from the practice log.

Source: doc/cheatsheet on GitHub — ratings and grouping live in data/cheatsheet_meta.json.