Analysis
5 pagesHow to reason about cost before you write a line, plus the two cheat-sheets you will keep open during practice.
- Big OLesson
- Spatial ComplexityLesson
- Trade OffsLesson
- Complexity cheat-sheetArticle
- Which pattern whenArticle
01 / ALGORITHMS
Start with how to measure (Big O, space, trade-offs), then the sorts and searches everyone is asked to explain, then recursion and the twelve interview patterns written as runnable JavaScript with asserts. The Holt lessons teach the idea; the prep sheets turn each idea into the problem shapes that show up in a 45-minute screen. Read the lesson, run the sheet, say the "SAY" line out loud.
How to reason about cost before you write a line, plus the two cheat-sheets you will keep open during practice.
Six classic sorts explained from first principles, then the comparators and partition tricks you actually use.
Binary search as a lesson, then the eleven shapes it hides inside (bounds, rotated arrays, search on the answer).
Recursion itself, then the two patterns built on it: backtracking and dynamic programming.
The reference sheets: arrays, strings, two pointers, sliding window, intervals, grids and bits.
| File | What's inside |
|---|---|
complexity-cheatsheet.md | Big-O tables: data structure ops, sorting algorithms, recurrences, vocabulary |
arrays.js | prefix sums, Kadane, two-sum, rotate (triple reverse), Dutch flag, product except self, merge sorted, cyclic sort / missing / duplicate (Floyd), Boyer-Moore majority, buy-sell stock, move zeroes |
strings.js | palindrome, anagram (freq[26]), reverse words, longest palindromic substring (expand center), LCP, compression, first unique, isomorphic, group anagrams, atoi, roman, KMP failure table, char-code math |
hash-maps.js | frequency idiom, two-sum, group anagrams, longest consecutive (Set), subarray sum = k (prefix map), dup within k, LRU via Map order, first non-repeating, intersection, top-k (bucket), HashMap design (chaining) |
two-pointers.js | two-sum II, 3-sum, container with most water, remove dups in place, sorted squares, trapping rain water, palindrome II, merge from back, Lomuto partition |
sliding-window.js | fixed + variable window TEMPLATES, max sum k, longest no-repeat, at most k distinct, min window substring, anagrams in string, max consecutive ones III, sliding max (monotonic deque) |
binary-search.js | lo<=hi template, lower/upper bound, insert position, first bad version, rotated search/min, peak, binary-search-on-answer (Koko, ship capacity, split array), 2D matrix, sqrt |
sorting.js | comparators, merge sort, quick sort (Lomuto + Hoare), quickselect, counting, bucket, heap sort, insertion, sort colors, merge intervals, TimSort note |
stacks-queues.js | valid parens, min stack, RPN, decode string, simplify path, queue via 2 stacks, stack via queue, monotonic stack TEMPLATE (next greater, daily temps, histogram, remove k digits), circular queue, O(1) queue head-index |
linked-lists.js | ListNode + helpers, reverse, middle, Floyd cycle + start, merge sorted, remove nth from end, reorder, palindrome, add two numbers, intersection, remove dups, DLL + LRU sketch, reverse k-group |
trees-bst.js | DFS pre/in/post, BFS level order, views (left/right/top/bottom), boundary, LCA, validate BST, serialize |
heaps.js | MinHeap class (comparator), kth largest, top-k frequent, merge k sorted, median stream (two heaps), k closest, task scheduler, meeting rooms II, reorganize string, ugly numbers |
graphs.js | adjacency list, BFS (+path), DFS rec/iter, components, islands, clone, cycle detect (3-color / parent), topo sort (Kahn + DFS), course schedule, Dijkstra, Bellman-Ford, Union-Find, Kruskal, bipartite, word ladder |
tries.js | Trie insert/search/startsWith/delete, autocomplete, word search II idea, LCP via trie, replace words, wildcard search, count prefix |
dynamic-programming.js | DP TEMPLATE, memo vs tab vs rolling; stairs, house robber I/II, coin change I/II, LIS (n^2 + n log n), LCS, edit distance, 0/1 + unbounded knapsack, unique paths, min path sum, word break, partition subset, decode ways, max product, LPS, Kadane |
backtracking.js | choose/explore/un-choose TEMPLATE; subsets I/II, permutations I/II, combinations, combination sum I/II, parentheses, phone letters, N-Queens, word search, palindrome partition, sudoku |
recursion.js | anatomy, fast pow, digit sum, reverse string, flatten, deep clone, Hanoi, memo fib, recursion -> explicit stack, TCO note, stack depth, mutual recursion |
intervals.js | merge, insert, non-overlapping (min removals), meeting rooms I/II (two-pointer + heap), arrows, intersection, employee free time, sort-by-start vs sort-by-end |
matrices.js | directions idiom, in-bounds, traversals, transpose, rotate CW/CCW, spiral, set zeroes O(1), search 2D I/II, islands, flood fill, max island, rotting oranges, diagonal, game of life, pascal, word search |
bit-manipulation.js | operator table, bit idioms, single number I/II, popcount (Kernighan), counting bits, reverse bits, missing via XOR, add without +, subsets via bitmask, bitmask visited |
Breadth-first pathfinding on a grid, from the Holt course.
Four problems solved twice with the same tests, so the pattern names stop being abstract.