cconnected.
Understand the pattern. Find your own way.Find your starting point
Small ideas, connected

Find a comfortable starting point.

Start small, or pick an idea you’re curious about.
You can revisit its stepping stones along the way.

State connects to recursion and invariants. Recursion leads to trees, graphs, backtracking, and tries. Repeated states lead to dynamic programming; safe choices lead to greedy algorithms.
01

Start small

A few small stepping stones

  1. Put a few things in a row
  2. Do one small thing again
  3. A rule can choose the next step
  4. Give a little task a name
  5. Take the top plate first
  6. The first person goes first
  7. Have we seen this before?
  8. Keep a little lookup notebook
  9. Join places with little lines
  10. A shelf needs two directions
02

The foundations

See the information that matters

  1. What does the future need to know?
  2. Count the work your model creates
  3. What makes it safe to throw half away?
  4. Split Array Largest Sum
  5. When can two moving boundaries replace a search?
  6. Subarray Sum Equals K
  7. Daily Temperatures
  8. Largest Rectangle in Histogram
03

Recursion

Make a smaller promise

  1. One call, one promise
  2. A call tree is a record of work
04

Arrays, search & sorting

Arrays: eliminate, order, partition, and sweep

  1. Two pointers: shrink one search space
  2. Container With Most Water
  3. Sorting: buy useful order
  4. Merge sort: combine ordered halves
  5. Quicksort: partition around a pivot
  6. Kth Largest Element
  7. Counting and radix sorting
  8. Binary search: find a boundary
  9. Search in Rotated Sorted Array
  10. Merge Intervals
  11. Sweep line: process boundary events
  12. Difference arrays: store changes
  13. Maximum Subarray
  14. Dutch flag: grow three regions
  15. First Missing Positive
  16. Hash tables: collisions need a plan
  17. Sliding Window Maximum
05

Linked lists

Linked lists: preserve references while reshaping

  1. Linked lists: follow references
  2. Reverse a linked list
  3. Linked List Cycle
  4. Merge two sorted linked lists
  5. Reorder List
  6. Copy List with Random Pointer
06

Trees

Pass information through a hierarchy

  1. What should a child tell its parent?
  2. Some information must travel downward
  3. Same tree shape, different promises
  4. Preorder and postorder are moments in one visit
  5. A BST inherits promises from every ancestor
  6. Where do two pieces of evidence meet?
  7. Kth Ancestor of a Tree Node
  8. What you return and what you measure can differ
  9. AVL tree: rebalance local height
  10. Serialize and restore a binary tree
07

Heaps & priority

Heaps: keep only the next priority ready

  1. Heap: keep the next extreme ready
  2. Top K Frequent Elements
  3. Merge k Sorted Lists
  4. Find Median from Data Stream
08

Range queries

Range queries: summarize intervals at different costs

  1. Coordinate compression: keep the order
  2. Fenwick tree: prefix sums with updates
  3. Segment tree: combine range summaries
  4. Sparse table: frozen overlapping ranges
09

Graphs

Routes, groups, costs, and cycles

  1. A graph is a language for legal moves
  2. BFS spreads in distance layers
  3. Rotting Oranges
  4. Word Ladder
  5. Visited means something different in different questions
  6. A dependency graph tells you what can happen next
  7. Explore every component, then enforce local constraints
  8. Sometimes you need groups, not routes
  9. Accounts Merge
  10. Redundant Connection
  11. Making A Large Island
  12. The cheapest frontier state can become final
  13. Minimum Cost to Make at Least One Valid Path in a Grid
  14. Path With Minimum Effort
  15. When a cheap route can get cheaper later
  16. Find the City With the Smallest Number of Neighbors at a Threshold Distance
  17. A cheapest network is not a set of cheapest routes
  18. Prim’s minimum spanning tree
  19. Swim in Rising Water
  20. Critical Connections in a Network
  21. Strongly connected components
  22. Find Eventual Safe States
  23. Bipartite graphs: alternate two colors
  24. Euler trail: use every edge once
  25. Maximum flow: reroute through residual edges
  26. Maximum bipartite matching
  27. A*: guide shortest-path search
  28. Articulation points: fragile vertices
  29. Reverse time for offline connectivity
10

Backtracking

Construct and undo possibilities

  1. Choose, explore, restore
  2. A bad-looking branch is not necessarily impossible
  3. N-Queens: place one row at a time
  4. Sudoku: choose the tightest blank
  5. Permutations with duplicates
  6. Combination Sum
11

Tries

Share beginnings

  1. Store the shared beginning once
  2. A data structure can guide a search
  3. A prefix finds a subtree; autocomplete explores it
  4. A board path and a word prefix advance together
12

String algorithms

Strings: reuse prefix, window, and symmetry work

  1. Rolling hash: compare windows cheaply
  2. KMP: reuse a matched prefix
  3. Z algorithm: match every suffix start
  4. Longest Palindromic Substring
  5. Suffix array: sort every starting point
13

Thinking in DP

Share equivalent futures, including graphs

  1. DP shares equivalent remaining questions
  2. Same dependencies, two ways to evaluate them
  3. Parallel Courses III
  4. Longest Increasing Path in a Matrix
  5. Cheapest Flights Within K Stops
14

1D dynamic programming

Grow a small answer along rows, trees, and words

  1. One index can summarize a whole remaining choice
  2. Pick-or-skip DP grows branches
  3. Sum of Distances in Tree
  4. Same coins, different question, different recurrence
  5. One coordinate does not mean one transition
  6. Word Break
  7. Word Break II
15

2D dynamic programming

Two coordinates describe the question

  1. A grid becomes DP when the dependencies stop cycling
  2. Two independent reading positions create a grid
  3. Edit Distance
  4. Progress and remaining capacity are different information
  5. An interval can be a subproblem boundary
  6. Burst Balloons
16

Extra state & 3D DP

Add only information the future needs

  1. The third coordinate is a missing fact
  2. Shortest Path in a Grid with Obstacles Elimination
  3. Three coordinates can describe two travelers
  4. Logical dimensions are not storage dimensions
  5. A visited set in a few bits
  6. Sometimes the history is a set you cannot forget
  7. Shortest Path Visiting All Nodes
17

Advanced DP patterns

Advanced DP: transform the state or transition

  1. Longest Increasing Subsequence faster
  2. Stock DP as a state machine
  3. Game DP: describe the advantage
  4. Digit DP: count without listing
  5. Profile DP: carry a boundary shape
  6. Meet in the middle
  7. Monotonic queue optimizes a DP window
  8. Probability DP: add disjoint outcomes
18

Greedy choices

Earn the right to commit

  1. A plausible local rule is a hypothesis
  2. Why earliest finish earns a commitment
  3. One changed objective takes us from greedy to DP
  4. Jump Game
  5. Schedule Courses before deadlines
  6. Huffman coding: merge cheapest weights
19

Bits, math & geometry

Bits, number theory, counting, and geometry

  1. Bits: tiny yes-or-no switches
  2. XOR: remember odd occurrences
  3. Prefix XOR: cancel a range
  4. Euclid: preserve the common divisors
  5. Sieve: cross out composite numbers
  6. Fast power and modular arithmetic
  7. Matrix exponentiation: jump linear states
  8. Combinatorics: count without generating
  9. Geometry: orientation before distance
  10. Reservoir sampling: choose from a stream
20

Connecting it all

Recognize the idea without the label

  1. Recognize the evidence, then choose the approach
21

Low-level design

Low-level design: give each piece a small promise

  1. Objects and responsibilities
  2. Let small objects work together
  3. Agree on a small promise
  4. Adapter: translate a boundary
  5. Facade: offer one clear entry point
  6. Keep changes from spreading everywhere
  7. Swap the rule, not the whole feature
  8. Decorator: wrap one extra behavior
  9. Choose how an object is built
  10. Builder: assemble a valid object
  11. Prototype: copy a configured starting point
  12. Abstract Factory: build compatible families
  13. Template Method: fix the workflow
  14. Factory Method: let a subtype choose construction
  15. Iterator: reveal items one at a time
  16. Tell interested objects what happened
  17. Command: make an action a value
  18. Memento: preserve a restorable snapshot
  19. Mediator: centralize collaboration
  20. Chain of responsibility: pass a request along
  21. Make legal actions visible
  22. Composite: treat a tree uniformly
  23. Bridge: separate two changing dimensions
  24. Visitor: add operations over stable types
  25. Interpreter: evaluate a tiny language
  26. Flyweight: share the repeated part
  27. Repository and unit of work
  28. LRU Cache
  29. Proxy: control access to a helper
  30. Design a parking lot
  31. Design a vending machine
  32. Design an elevator controller
  33. Design an expense ledger
  34. Make failure and retries part of the design
  35. Singleton and object lifetime
22

High-level design

High-level design: connect promises across machines

  1. Start with the system’s promises
  2. Follow one request across the network
  3. Make an API safe to call again
  4. Monolith, services, and ownership
  5. Share traffic across replaceable workers
  6. Choose storage from reads and writes
  7. Copies, lag, leaders, and agreement
  8. Split ownership without creating a hot corner
  9. Keep a nearby copy with an expiry story
  10. Let work wait without losing its identity
  11. Separate metadata from large bytes
  12. Contain failure instead of multiplying it
  13. Ask which version a read is allowed to see
  14. Commit the change and its event together
  15. Coordinate a workflow without one global transaction
  16. Give traffic a refillable budget
  17. Make the system’s promises measurable
  18. Check who may do what to which object
  19. Estimate the bottleneck before adding servers
  20. Design a URL shortener
  21. Design a social feed
  22. Design a chat service
  23. Design resumable file uploads
  24. Design a notification pipeline
  25. Design search and autocomplete
  26. Design a polite web crawler
  27. Design a streaming counter
  28. Explain a design through its tradeoffs