01 / ALGORITHMS

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.

Start here 27 pages · 7 groups

Searching

2 pages

Binary search as a lesson, then the eleven shapes it hides inside (bounds, rotated arrays, search on the answer).

  1. Binary SearchLesson
  2. Binary search patterns15 sections

Patterns

7 pages

The reference sheets: arrays, strings, two pointers, sliding window, intervals, grids and bits.

Files table from algorithms/README.md
FileWhat's inside
complexity-cheatsheet.mdBig-O tables: data structure ops, sorting algorithms, recurrences, vocabulary
arrays.jsprefix 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.jspalindrome, 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.jsfrequency 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.jstwo-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.jsfixed + 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.jslo<=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.jscomparators, merge sort, quick sort (Lomuto + Hoare), quickselect, counting, bucket, heap sort, insertion, sort colors, merge intervals, TimSort note
stacks-queues.jsvalid 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.jsListNode + 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.jsDFS pre/in/post, BFS level order, views (left/right/top/bottom), boundary, LCA, validate BST, serialize
heaps.jsMinHeap 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.jsadjacency 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.jsTrie insert/search/startsWith/delete, autocomplete, word search II idea, LCP via trie, replace words, wildcard search, count prefix
dynamic-programming.jsDP 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.jschoose/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.jsanatomy, fast pow, digit sum, reverse string, flatten, deep clone, Hanoi, memo fib, recursion -> explicit stack, TCO note, stack depth, mutual recursion
intervals.jsmerge, 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.jsdirections 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.jsoperator table, bit idioms, single number I/II, popcount (Kernighan), counting bits, reverse bits, missing via XOR, add without +, subsets via bitmask, bitmask visited
  1. Arrays13 sections
  2. Strings13 sections
  3. Two Pointers9 sections
  4. Sliding Window11 sections
  5. Intervals10 sections
  6. Matrices (2-D Grids)16 sections
  7. Bit Manipulation11 sections

Graph algorithms

1 pages

Breadth-first pathfinding on a grid, from the Holt course.

  1. PathfindingLesson