Find a comfortable starting point.
Start small, or pick an idea you’re curious about.
You can revisit its stepping stones along the way.
Start small
A few small stepping stones
The foundations
See the information that matters
Recursion
Make a smaller promise
Arrays, search & sorting
Arrays: eliminate, order, partition, and sweep
- Two pointers: shrink one search space
- Container With Most Water
- Sorting: buy useful order
- Merge sort: combine ordered halves
- Quicksort: partition around a pivot
- Kth Largest Element
- Counting and radix sorting
- Binary search: find a boundary
- Search in Rotated Sorted Array
- Merge Intervals
- Sweep line: process boundary events
- Difference arrays: store changes
- Maximum Subarray
- Dutch flag: grow three regions
- First Missing Positive
- Hash tables: collisions need a plan
- Sliding Window Maximum
Linked lists
Linked lists: preserve references while reshaping
Trees
Pass information through a hierarchy
- What should a child tell its parent?
- Some information must travel downward
- Same tree shape, different promises
- Preorder and postorder are moments in one visit
- A BST inherits promises from every ancestor
- Where do two pieces of evidence meet?
- Kth Ancestor of a Tree Node
- What you return and what you measure can differ
- AVL tree: rebalance local height
- Serialize and restore a binary tree
Heaps & priority
Heaps: keep only the next priority ready
Range queries
Range queries: summarize intervals at different costs
Graphs
Routes, groups, costs, and cycles
- A graph is a language for legal moves
- BFS spreads in distance layers
- Rotting Oranges
- Word Ladder
- Visited means something different in different questions
- A dependency graph tells you what can happen next
- Explore every component, then enforce local constraints
- Sometimes you need groups, not routes
- Accounts Merge
- Redundant Connection
- Making A Large Island
- The cheapest frontier state can become final
- Minimum Cost to Make at Least One Valid Path in a Grid
- Path With Minimum Effort
- When a cheap route can get cheaper later
- Find the City With the Smallest Number of Neighbors at a Threshold Distance
- A cheapest network is not a set of cheapest routes
- Prim’s minimum spanning tree
- Swim in Rising Water
- Critical Connections in a Network
- Strongly connected components
- Find Eventual Safe States
- Bipartite graphs: alternate two colors
- Euler trail: use every edge once
- Maximum flow: reroute through residual edges
- Maximum bipartite matching
- A*: guide shortest-path search
- Articulation points: fragile vertices
- Reverse time for offline connectivity
Backtracking
Construct and undo possibilities
Tries
Share beginnings
String algorithms
Strings: reuse prefix, window, and symmetry work
Thinking in DP
Share equivalent futures, including graphs
1D dynamic programming
Grow a small answer along rows, trees, and words
2D dynamic programming
Two coordinates describe the question
Extra state & 3D DP
Add only information the future needs
Advanced DP patterns
Advanced DP: transform the state or transition
Greedy choices
Earn the right to commit
Bits, math & geometry
Bits, number theory, counting, and geometry
- Bits: tiny yes-or-no switches
- XOR: remember odd occurrences
- Prefix XOR: cancel a range
- Euclid: preserve the common divisors
- Sieve: cross out composite numbers
- Fast power and modular arithmetic
- Matrix exponentiation: jump linear states
- Combinatorics: count without generating
- Geometry: orientation before distance
- Reservoir sampling: choose from a stream
Connecting it all
Recognize the idea without the label
Low-level design
Low-level design: give each piece a small promise
- Objects and responsibilities
- Let small objects work together
- Agree on a small promise
- Adapter: translate a boundary
- Facade: offer one clear entry point
- Keep changes from spreading everywhere
- Swap the rule, not the whole feature
- Decorator: wrap one extra behavior
- Choose how an object is built
- Builder: assemble a valid object
- Prototype: copy a configured starting point
- Abstract Factory: build compatible families
- Template Method: fix the workflow
- Factory Method: let a subtype choose construction
- Iterator: reveal items one at a time
- Tell interested objects what happened
- Command: make an action a value
- Memento: preserve a restorable snapshot
- Mediator: centralize collaboration
- Chain of responsibility: pass a request along
- Make legal actions visible
- Composite: treat a tree uniformly
- Bridge: separate two changing dimensions
- Visitor: add operations over stable types
- Interpreter: evaluate a tiny language
- Flyweight: share the repeated part
- Repository and unit of work
- LRU Cache
- Proxy: control access to a helper
- Design a parking lot
- Design a vending machine
- Design an elevator controller
- Design an expense ledger
- Make failure and retries part of the design
- Singleton and object lifetime
High-level design
High-level design: connect promises across machines
- Start with the system’s promises
- Follow one request across the network
- Make an API safe to call again
- Monolith, services, and ownership
- Share traffic across replaceable workers
- Choose storage from reads and writes
- Copies, lag, leaders, and agreement
- Split ownership without creating a hot corner
- Keep a nearby copy with an expiry story
- Let work wait without losing its identity
- Separate metadata from large bytes
- Contain failure instead of multiplying it
- Ask which version a read is allowed to see
- Commit the change and its event together
- Coordinate a workflow without one global transaction
- Give traffic a refillable budget
- Make the system’s promises measurable
- Check who may do what to which object
- Estimate the bottleneck before adding servers
- Design a URL shortener
- Design a social feed
- Design a chat service
- Design resumable file uploads
- Design a notification pipeline
- Design search and autocomplete
- Design a polite web crawler
- Design a streaming counter
- Explain a design through its tradeoffs