120 chapters. 15 parts. Open.
Every chapter, ordered by part — foundations through interview framework. Multi-language solutions and animated walkthroughs throughout.
- Chapters
- 120
- Words
- 338,428
- Parts
- 15
No chapters match those filters
Try clearing one of the active filters — or reset them all.
Foundations
The do-not-skip prerequisites. Big-O, recursion, bit ops, math for interviews, language idioms. Most readers want to skip Part 0 and shouldn't.
- How to use this handbook How to read this handbook: who it's for, what to skip, how to pick a language, and the four questions every DSA resource ducks. beg 10 min
- Computational complexity and Big-O Computational complexity, Big-O, and the asymptotic vocabulary every algorithm chapter assumes you have. The five Bachmann-Landau notations. beg 15 min
- The recursion mental model The mental model for recursion: base case, recursive case, and how to read tree-shaped recursion without losing your place. beg 20 min
- Bit manipulation primer Bit manipulation primer: AND, OR, XOR, NOT, shifts, popcount. The bit-level idioms that show up in interview problems. beg 10 min
- Math for interviews The math you actually need for technical interviews: modular arithmetic, GCD, primality, combinatorics, integer overflow. beg 20 min
- Language idioms across Python, Java, C++, Go Idiomatic patterns for Python, Java, C++, and Go: collections, iteration, sorting, comparators. The dialect each language wants you to write. beg 8 min
- Choosing your interview language How to pick a language for technical interviews: trade-offs, what each language costs you in problem-solving time, and a decision tree. beg 10 min
Linear Data Structures
Arrays, dynamic arrays, strings, hash maps, hash collisions, stacks, queues, deques, matrix manipulation. The vocabulary every interview problem assumes you have.
- Arrays: static, dynamic, multi-dimensional Arrays: contiguous memory, O(1) indexing, and the operations that differ between fixed-size arrays and dynamic arrays. beg 10 min
- Dynamic array internals How dynamic arrays grow: amortised O(1) append, the doubling trick, capacity vs length, and what each language calls them. int 15 min
- Strings: encoding, immutability, builders Strings as character arrays and beyond: immutability, encoding, concatenation cost, and the per-language trade-offs that catch interviews out. beg 15 min
- Hash maps and hash sets Hash maps from first principles: hash functions, buckets, average vs worst-case complexity, and the standard library implementations. int 20 min
- Hash collisions and the load factor Hash collisions: separate chaining, open addressing, load factor, rehashing, and why hash maps degrade to O(n) under adversarial keys. adv 20 min
- Stacks and the call stack analogy Stacks as data structures and algorithmic primitives: LIFO, function-call stacks, and the interview problems that scream 'stack'. beg 20 min
- Queues, deques, and circular buffers Queues and deques: FIFO, double-ended, ring buffers, and the BFS / sliding-window problems where the right primitive is a deque. int 15 min
- Matrix manipulation 2D arrays and matrix manipulation: in-place rotation, transposition, spiral traversal, and indexing without off-by-one bugs. int 15 min
Search and Sort
Linear search, binary search variants, comparison sorts, heap sort, linear sorts, quickselect. The first place algorithmic thinking shows up.
- Linear search and what it's good for Linear search: when O(n) is the right answer, and the problems where the trick is recognising you don't need anything cleverer. beg 15 min
- Binary search: the canonical version Binary search done right: the canonical template, off-by-one pitfalls, and the invariant you need to articulate before writing the loop. int 20 min
- Binary search variants: lower_bound, upper_bound, peaks, and rotated arrays Binary search beyond sorted arrays: lower_bound, upper_bound, first-true, last-true, and binary search on the answer space. int 20 min
- Comparison sorts I: insertion sort and merge sort Insertion, selection, and bubble sort: O(n^2) sorts, when each wins on real input, and the constant-factor lessons that hide inside them. int 15 min
- Comparison sorts II: quicksort, partition, and the production hybrids Merge sort and quicksort: divide-and-conquer, partitioning, stability, and why production library sorts are hybrid algorithms. int 20 min
- Heap sort and the n log n lower bound Heap sort and the binary heap: heapify, sift-up, sift-down, and why a heap is the right tool for k-way merges and priority queues. int 20 min
- Linear-time sorts: counting, radix, bucket Counting sort, radix sort, bucket sort: O(n) sorts that beat the comparison-sort lower bound when the input has structure. int 15 min
- Quickselect: linear-time selection Quickselect: O(n) average kth-smallest, partitioning, and the problems where you can dodge a full sort by selecting only the part you need. int 20 min
Pointers, Window, Prefix
Two-pointer techniques, fixed and variable sliding windows, prefix sums, and prefix-sum-plus-hash. The highest interview-ROI part of the curriculum.
- Two pointers: opposite ends Two pointers, opposite ends: the inward sweep, sorted-array invariants, and the canonical 'sum to target' / 'pair under constraint' patterns. int 20 min
- Two pointers: same direction Two pointers, same direction: fast-slow pointers, in-place filtering, and the array problems that disguise this pattern. beg 15 min
- Sliding window: fixed size Fixed-size sliding windows: maintaining a running aggregate in O(1) per step, and the problems whose constraint is window length. int 15 min
- Sliding window: variable size Variable-size sliding windows: shrinking when the invariant breaks, and the longest-substring / minimum-window problem family. int 20 min
- Prefix sums and difference arrays Prefix sums: O(1) range-sum queries, 2D extensions, and the subarray-sum problems that simplify once the right precomputation is in place. beg 20 min
- The prefix-sum + hash-map combo Prefix sum + hash map: counting subarrays with a target sum, the canonical 'subarray sum equals K' problem family, and modulo extensions. int 20 min
Stack and Queue Patterns
Monotonic stacks, parentheses matching, BFS-on-deque, sliding-window maximum. Stack and queue as algorithmic primitives, not data structures.
- Monotonic stack Push indices, pop while the incoming value violates a monotone order. The data structure designed for the intersection of nearest-greater queries and one-pass l… int 20 min
- Monotonic deque Pop from both ends to maintain a windowed running max or min in O(1) amortized per slide. The structure that makes sliding-window-extremum problems linear inste… int 20 min
- Min and max stacks Augment a stack with an O(1) aggregate query by pinning a parallel auxiliary stack to it; scale the technique from running min to lazy bulk-update to frequency … int 20 min
- Expression evaluation and parsing Stacks suspend operators until their right operand exists. The shunting-yard rhythm and the LeetCode 224/227/772 family where the order characters arrive in is … int 15 min
- Queue from stacks Implement a queue using only stack primitives. The two-stack lazy-transfer trick, amortized O(1) on every operation, and why the LIFO-from-FIFO inverse has no s… int 20 min
Linked Lists
Pointer rewiring, cycle detection, k-way merge, LRU cache. Bridges to Part 13's design problems.
- Linked list fundamentals: sentinels, pointer rewiring, doubly-linked design Sentinel and dummy nodes erase the boundary branching that special-cases head and tail. The pointer-rewiring discipline and the doubly-linked design every later… beg 20 min
- Reversal patterns Reverse a singly-linked list in place with prev, curr, next. The snapshot-then-clobber rule, plus the iterative and recursive forms that show up as a primitive … int 15 min
- Reverse in groups of k Three mechanical phases stacked on single-list reversal solve LeetCode 25 in O(1) extra memory, with the seam between groups handled cleanly. int 15 min
- Cycle detection (Floyd's tortoise and hare) Two pointers, one stepping twice as fast as the other, locate a cycle's entry node in O(n) time and O(1) space. The modular-arithmetic three-line proof of why t… int 20 min
- Merging linked lists Merge sorted linked lists in place. The dummy-head trick that erases the first-node special case, two-list and k-list versions, and the heap-based and divide-an… int 15 min
- LRU cache: hash map plus doubly linked list Build the data structure behind LeetCode 146 from a doubly-linked list and a hash map. O(1) get and put with explicit list management, no shortcut through Pytho… int 20 min
Trees and Heaps
Tree traversals, BSTs, balanced trees, heaps, priority queues, tries. The most-asked topic class in mid-level interviews.
- Binary tree fundamentals Tree terminology, height vs depth, the two physical representations, and the on-disk vocabulary every later Part 6 chapter assumes you have pinned down. beg 20 min
- Tree traversals: pre, in, post One recursive skeleton has three positions for the visit() call. The pre, in, and post placements solve different problem families on the same scaffolding. int 20 min
- Morris traversal: O(1)-space inorder by threading Walk a binary tree in inorder with no recursion stack and no auxiliary memory by threading temporary right-pointers from each subtree's rightmost descendant bac… adv 20 min
- Level-order traversal: BFS on trees BFS on trees, with the level_size = len(queue) snapshot that turns 'visit every node' into 'visit every node grouped by depth' with the boundaries preserved. int 15 min
- Heaps and priority queues Sift-up and sift-down, Floyd's O(n) bottom-up build vs O(n log n) repeated insert, and the language-by-language API for the priority-queue primitive. int 30 min
- Binary search trees The BST invariant, search/insert/delete operations, and why every shipping standard library uses a balanced variant instead of a plain BST. int 15 min
- AVL trees and rotations Self-balancing BSTs from first principles: the AVL invariant, the four rotation cases, the 1.44 log(n+2) height bound, and why every production ordered map desc… adv 20 min
- Red-black trees: an overview The balancing scheme behind TreeMap, std::map, and the Linux scheduler. Five invariants, the rotation cases at a high level, and what an interview can reasonabl… int 15 min
- Tries Children-map-plus-end-flag nodes give prefix walks in O(L) on query length. The autocomplete and IP-routing problem family where prefix structure is the whole p… int 15 min
- Tree DP primer: post-order with side state Post-order helpers thread side state down through arguments, return aggregates up the call stack, and use a global to track diameter-style through-this-node opt… int 20 min
- Segment trees O(log n) point updates and O(log n) range queries on the same array. The recursive build and the lazy-propagation extension for range updates. adv 20 min
Recursion and Backtracking
Recursion mental model, backtracking templates, divide-and-conquer, permutations, combinations, subset generation. Pre-DP.
- Recursion patterns: linear, tree, and divide-and-conquer Three call-tree shapes — linear, tree, divide-and-conquer — and how to read the shape from the recursive case so you know whether you need memoization, an accum… int 20 min
- The backtracking template Choose, recurse, unchoose, with prune-on-partial-information as the move that turns exponential search into something that finishes. int 20 min
- Subsets, combinations, permutations One recursion with three knobs (when to snapshot the path, what to skip, when to allow repeats) covers subsets (LC 78), permutations (LC 46), and combination su… int 20 min
- N-Queens: pruning and constraint propagation Column and diagonal occupancy bitsets give O(1) attack checks. Symmetry pruning and the constraint-propagation idea that generalizes to Sudoku and beyond. adv 20 min
- Sudoku solver: constraint propagation and forward checking Row, column, and box bitmasks combined with MRV cell selection and a forward-checking loop solve a 9x9 in milliseconds, despite 4 × 10^38 candidate fillings. adv 15 min
- Word search and grid backtracking Grid DFS with mark-and-restore: the in-place visited trick that turns a 2D backtracking problem into one clean recursion. int 20 min
- Randomized algorithms: Fisher-Yates, reservoir sampling, rejection sampling Three randomized recipes — Fisher-Yates shuffle, reservoir sampling, rejection sampling — whose proofs of uniform correctness are the actual lesson, not the cod… adv 25 min
Graphs
BFS, DFS, topological sort, shortest paths, MSTs, graph colouring, union-find. The largest topic-coverage part; bridges to Part 9.
- Graph representation Three ways to store a graph (adjacency list, adjacency matrix, edge list), the memory math that decides between them, and the default every interview assumes. beg 15 min
- Breadth-first search Queue, visited set, and the discipline of never enqueuing the same vertex twice. The shortest-path-on-unweighted-edges algorithm, plus its multi-source and grid… int 20 min
- Depth-first search Five lines that visit on entry and recurse on neighbors, plus the customization knobs (entry hook, exit hook, edge classification) every advanced graph algorith… int 15 min
- Connected components and flood fill Counting and measuring components in a graph or grid: the outer scan that turns plain BFS or DFS into the algorithm. int 20 min
- Topological sort: Kahn's algorithm Indegree-driven, queue-based, iterative. Kahn's algorithm flags a cycle by failing to consume every vertex. int 15 min
- Topological sort: DFS post-order reverse DFS-based topological sort: three-color recursion, post-order emission, and the algorithms that fall out of the same skeleton — Tarjan's bridges, Hierholzer's E… int 20 min
- Cycle detection in graphs Three-state DFS coloring for directed cycles, parent-aware single-state DFS for undirected, and the bug both halves share when the wrong one is used. int 20 min
- Bipartite check Two-color a graph by BFS or DFS. The odd-cycle obstruction, the linear-time check, and the problem family that disguises this question as 'split into two groups… int 15 min
- Union-Find: parent forests, path compression, and union by rank Parent forests, union by rank, path compression, and the inverse-Ackermann amortized bound. The cycle-detection and connected-components problem family it owns. int 25 min
- Dijkstra's shortest-path algorithm Single-source shortest paths on weighted graphs with non-negative edges: the priority-queue mechanics, the lazy-deletion idiom, and the min-max-path and 0-1 BFS… adv 20 min
- Bellman-Ford and negative cycles V-1 edge relaxations on every edge, an extra Vth pass to detect negative cycles, and the algorithm that handles the negative-edge case Dijkstra silently mis-rep… adv 20 min
- Minimum spanning tree: Kruskal's algorithm Kruskal's algorithm: sort edges by weight, accept each one whose endpoints sit in different components, halt at n-1 edges. The cycle check is union-find; the co… adv 20 min
- Minimum spanning trees: Prim's algorithm Prim's algorithm grows a minimum spanning tree from a single start vertex by absorbing the cheapest crossing edge. Same MST as Kruskal, different path; better c… adv 15 min
Dynamic Programming
Memoization, tabulation, classic DP patterns (LIS, LCS, edit distance, knapsack), DP on trees and graphs, bitmask DP. The hardest topic class.
- Dynamic Programming: From Recursion to Memoization When a recursion's call tree carries redundancy, an eight-character cache drops Fibonacci from O(phi^n) to O(n). The systematic move from naive recursion to mem… int 20 min
- DP: bottom-up tabulation Convert memoized recursion to an iterative table fill: dependency DAG, topological order, loop, array. Plus the rolling-pair O(1) compression. int 20 min
- Dynamic programming on a 1D state 1D-state DP: when the answer at index i depends on a small fixed window of earlier indices. Climbing stairs, house robber, min cost climbing stairs, and the rol… int 15 min
- Decode Ways and Word Break: string-prefix decision DP Two string-prefix decision DPs whose recurrences look different but run on the same dp[i] = OR-over-valid-splits skeleton. LC 91 Decode Ways and LC 139 Word Bre… int 20 min
- 0/1 knapsack 0/1 knapsack: take-or-skip per item, the 1D table fill, why the inner loop sweeps right-to-left, and the family of subset-sum reformulations (LC 416, 494, 474, … int 15 min
- Unbounded knapsack: when items can be picked over and over One inner-loop direction reversed from 0/1 knapsack unlocks the coin-change family. How 'minimum coins', 'count of ways', and 'minimum cost' all fit one recurre… int 20 min
- Longest common subsequence The O(n*m) 2D DP for longest common subsequence, parent-pointer recovery for the actual subsequence, and the edit-distance and shortest-common-supersequence var… int 30 min
- Edit distance Wagner-Fischer's three-way recurrence for the minimum number of insertions, deletions, and replacements that turn one string into another. The canonical 2D stri… int 15 min
- Longest Increasing Subsequence: the quadratic DP Per-index dp[i] = max-over-smaller-predecessors gives the O(n^2) LIS. Parent-pointer recovery and the variants (LIS count, LIS with k-tolerance) that stay quadr… int 15 min
- LIS: patience sort From 9.8's O(n^2) DP to O(n log n): the patience-sort framing, the tails-array invariant, binary search by tail value, and the LC 354 sort-then-LIS reduction. adv 20 min
- Palindrome DP Filling a 2D table whose recurrence reads dp[i+1][j-1] forces a diagonal fill order. The longest-palindromic-substring and min-cuts family that lives on it. int 20 min
- Interval DP: matrix chain and burst balloons State is dp[l][r], and the recurrence picks the LAST operation in the range. Burst Balloons (LC 312) and Matrix Chain Multiplication (LC 1039) are the canonical… adv 20 min
- Grid DP: forward fills, backward survives Top-down forward fills (Unique Paths, Min Path Sum) and bottom-up backward survives (Dungeon Game). The direction is picked by whether the constraint applies at… int 25 min
- Tree DP: states that travel up the call stack Post-order helpers that return more than one number to the parent — (rob, skip), (diameter, depth) — centered on LC 337 House Robber III and LC 124 Max Path Sum… adv 20 min
- Bitmask DP A subset of a small ground set encoded as one integer, dp[mask] = ..., and the assignment / TSP / shortest-path-visiting-all family where this state is the only… adv 20 min
Greedy
Greedy proofs, exchange arguments, interval scheduling, Huffman coding.
- Greedy thinking: when local choices win, and when they don't When the locally-best choice provably aggregates to the globally-best answer. The exchange-argument proof technique and the failure modes where greedy looks rig… int 20 min
- Interval scheduling: the comparator is the algorithm Sort by end time and you've picked the maximum non-overlapping subset. The comparator (not the DP, not the heap) is the entire algorithm. int 15 min
- Activity selection and the task-scheduler family A max-heap of remaining tasks paired with a cooldown queue. The same skeleton solves LC 621 Task Scheduler, room booking, and conference assignment. int 15 min
- Huffman encoding Build the optimal prefix-free code bottom-up by repeatedly merging the two least-frequent symbols. The optimality proof and why this construction wins where top… int 20 min
- Jump games and gas station Two array problems that look O(n^2), both solved by a single linear pass that maintains one running quantity. LC 55 Jump Game and LC 134 Gas Station. int 25 min
Bit Manipulation
Bit tricks, XOR techniques, bitmask enumeration, single-number patterns.
- Bit operations cookbook The two identities the rest of Part 11 stands on: x & -x for the lowest set bit, x & (x-1) to clear it. Plus popcount, set/clear/flip/test, and subset iteration… int 15 min
- XOR patterns XOR patterns: pair-cancellation as a bit-vector group law, and the family of LC problems it solves in O(n) time and O(1) space. int 15 min
- Bitmask techniques Encode a small set as an integer; iterate every subset; walk the submasks of a mask. The substrate behind bitmask DP. int 15 min
- Bit tricks for performance A toolkit of bit-pattern identities — Brian Kernighan's loop, x & -x, SWAR popcount, de Bruijn bit-scan — and the hardware intrinsics that have made most of the… adv 15 min
Strings and Pattern Matching
Naive matching, KMP, Rabin-Karp, Z-algorithm, suffix arrays. Strings as first-class objects, not character arrays.
- Naive string matching The O(nm) double loop hidden inside str.find and str.indexOf. Average-case behavior on real text, and the adversarial inputs that motivate KMP and Rabin-Karp. int 10 min
- Rabin-Karp and rolling hashes Rolling hashes give O(1)-per-slide hash maintenance for fixed-length windows. Double hashing defeats adversarial collisions and unlocks the duplicate-substring … int 20 min
- KMP and the failure function Knuth-Morris-Pratt: deterministic O(n+m) substring search via the failure function, and the prefix-suffix table that solves a small family of problems on its ow… adv 15 min
- Z-algorithm Z-array as the prefix-match table on a string; the [l, r) window invariant that makes it linear; how it compares with KMP for exact pattern matching. adv 20 min
- Aho-Corasick: many patterns, one pass A trie with failure links: how Aho-Corasick scans a text once and reports every occurrence of every pattern in a fixed dictionary in O(n + m + z) time. adv 20 min
- Suffix arrays: a sorted index of every suffix A sorted index of every suffix in roughly 4n bytes, plus the LCP array. The substring-search, longest-repeated-substring, and BWT applications built on these tw… adv 20 min
Design the Data Structure
Design problems: LRU, LFU, autocomplete, rate limiter, time-series store. Composing data structures into interview-grade systems.
- LRU cache: design framing, concurrency, and multi-tier deployment Pointer rewiring is the warm-up for LeetCode 146. Thread-safety, multi-tier deployment, and Caffeine-style admission policies are the actual interview. int 20 min
- LFU cache: hash map plus frequency-bucketed doubly linked lists A hash map keyed by frequency, each value a doubly-linked list of equally-frequent entries, plus a min-frequency tracker. The construction that earns LeetCode 4… adv 20 min
- Min stack and max-frequency stack Two design problems, one technique. Pin a parallel auxiliary to a stack and the augmented operation collapses to a peek; the auxiliary's shape tracks the contra… int 15 min
- Hit counter and rate limiter Fixed-window, sliding-window-log, and token-bucket variants of LC 362 Design Hit Counter, with the precision-and-memory trade-offs that production systems (Clou… int 25 min
- Trie autocomplete Per-node ranked top-k cache, persistent suggestions across keystrokes, and the design moves that take a vanilla trie from O(L + answers) to single-digit-microse… adv 15 min
- Twitter feed design LC 355 Design Twitter as a mechanics-driven design class: monotonic timestamps, per-user append-only logs, and a k-way merge through a heap of author cursors fo… adv 20 min
- Game state design Store the answer the board would give, not the board itself. Per-row, per-column, per-diagonal counters give LC 348 Tic-Tac-Toe O(1) per move and O(n) memory to… int 15 min
Interview Framework
The interview framework: clarifying questions, brute-force-then-optimise, complexity articulation, edge cases, code walk-through, and company-specific flavours.
- Pattern recognition: the fastest skill to develop The twenty patterns that cover ~95% of new-grad FAANG coding rounds, the top five that cover half on their own, and the recognition rhythm that names the patter… int 10 min
- The first five minutes: clarifying questions What to ask in the first five minutes. The questions interviewers grade you on, the prompts that signal seniority, and the failure mode that costs the most cand… int 9 min
- Communicating during the interview Thinking aloud, narrating trade-offs, and the interviewing.io data showing the 4-4-2 candidate beats the 3-3-4 candidate on outcomes. int 10 min
- Complexity discussions How to answer 'what's the time complexity?' in one sentence: derive vs memorize, time alongside space, the right qualifier (worst/average/amortized), all four s… int 9 min
- The mock interview process When to start mocking, which platform to use, how many mocks you actually need, and how to run a debrief that converts a session into signal. int 10 min
- Common pitfalls The five highest-leverage failure modes at FAANG-tier loops: jumping to code, silent solving, missed clarifications, unstructured complexity answers, and the si… int 10 min
- Amazon Leadership Principles, briefly Which Leadership Principles surface most in coding rounds, why the chat at minute 5 and minute 50 is part of the rubric, and the rounds where 'I'll just be exce… int 10 min
- Amazon Leadership Principles narration STAR-format micro-narrations for the technical rounds, plus the eight to twelve full stories the behavioral and Bar Raiser rounds expect candidates to walk in c… int 9 min
- Meta's AI round: the format What Meta's AI-assisted coding round actually is in 2026: 60 minutes, three phases, a model menu, and a rubric that grades how you use the AI more than what the… int 10 min
- Meta's AI round: prompting tactics Prompting tactics for an AI-assisted coding round. The three-tier hierarchy (orchestrator, spot-checker, typist) that produces the behavior the rubric scores. int 10 min
- Meta's AI round: common failures Candidates who treat the assistant as a solver, candidates who can't explain their own code, and the system-prompt hardening that breaks any prep built on 'AI w… int 15 min
- Per-company tracks: index and how to use When to open a per-company track, how to layer it on Parts 0-13, and the three signals that tell you it's time to move from pattern practice to company-specific… int 5 min