Skip to content
FollowtheDamnCode

Data structures and algorithms

34 topics in teaching order. The first 3 are free, with every lesson. The rest are part of Pro.

  1. 1Complexity AnalysisBig-O, space, amortized cost, and reading a problem's limits to know which algorithm will pass.
  2. 2ArraysContiguous memory with instant indexing — the structure almost every other one is built on.
  3. 3StringsCharacter arrays with their own traps — building, counting, palindromes, matching, and parsing.
  4. 4HashingHash maps and sets — O(1) average lookups that turn "search every item" into "ask directly". Pro
  5. 5Two PointersTwo indices moving with a rule — pairs in sorted arrays, in-place filtering, merging, and 3Sum. Pro
  6. 6Sliding WindowA contiguous range that grows on the right and shrinks on the left — subarray and substring questions in O(n). Pro
  7. 7Prefix SumsPrecompute running totals once, then answer any range-sum question with one subtraction. Pro
  8. 8StackLast in, first out — matching brackets, undo, nested structure, and expression evaluation. Pro
  9. 9QueueFirst in, first out — fair ordering, BFS, and the deque that does both ends. Pro
  10. 10Monotonic Stack & QueueKeep a stack or deque in sorted order to answer "next greater", "largest rectangle", and sliding-window max in O(n). Pro
  11. 11Linked ListNodes joined by pointers — O(1) rewiring, no indexing, and a handful of pointer patterns. Pro
  12. 12RecursionSolve a problem by trusting a smaller copy of itself — the base for trees, backtracking, and DP. Pro
  13. 13SortingPutting data in order — the classic algorithms, when each wins, and sorting as a first step. Pro
  14. 14Binary SearchHalve the search space each step — on sorted arrays, and on the answer itself. Pro
  15. 15TreeHierarchical nodes — traversals, recursive subtree answers, binary search trees, and construction. Pro
  16. 16Heap & Priority QueueAlways know the smallest (or largest) item — top-k, scheduling, merging, running medians. Pro
  17. 17TrieA tree built for prefixes — autocomplete, dictionaries, and searching many words at once. Pro
  18. 18GraphThings and the connections between them — representations, BFS, DFS, components, cycles, and grids. Pro
  19. 19Topological SortOrder tasks so every prerequisite comes first — and detect when no such order exists. Pro
  20. 20Shortest PathsCheapest routes through weighted graphs — Dijkstra, 0-1 BFS, Bellman-Ford, and Floyd-Warshall. Pro
  21. 21Union-FindTracking which items are connected as you merge groups — in near-constant time per operation. Pro
  22. 22Minimum Spanning TreeConnect every vertex at the lowest total cost — Kruskal's sorted edges or Prim's growing tree. Pro
  23. 23GreedyMake the best-looking choice at each step — fast and simple, when you can prove it's safe. Pro
  24. 24IntervalsRanges with a start and end — overlap tests, merging, and counting how many run at once. Pro
  25. 25BacktrackingBuild candidates one choice at a time, undo the latest choice at a dead end — "generate all" and constraint puzzles. Pro
  26. 26Dynamic ProgrammingSolve each overlapping subproblem once, store it, and build the answer from stored pieces. Pro
  27. 27Bit ManipulationTreat an integer as a row of switches — test, set, flip, and count bits, XOR tricks, and bitmask sets. Pro
  28. 28MathGCD, primes, modular arithmetic, fast powers, digit tricks, and counting — formulas that replace loops. Pro
  29. 29Matrix2D grids — traversal orders, in-place rotation and marking, and searching sorted matrices. Pro
  30. 30Cyclic SortWhen values are 1..n, each value names its own index — sort in O(n) and find missing or duplicate numbers in O(1) space. Pro
  31. 31QuickselectFind the k-th smallest element in O(n) on average — partition like quicksort, then recurse into one side only. Pro
  32. 32Segment TreeRange queries and point updates in O(log n) — sums, minimums, maximums, and more. Pro
  33. 33Fenwick Tree (BIT)Prefix sums that also support updates — both in O(log n), in about ten lines of code. Pro
  34. 34Bloom Filters & Skip ListsTwo probabilistic structures — a tiny set that may say "yes" wrongly, and a sorted list that stays fast by flipping coins. Pro