Coding problems and trade-offs
Solve unfamiliar problems and explain correctness, boundaries, and trade-offs.
Solve a specified problem before changing its requirements
A transaction list, a schedule, or a dependency graph gives you concrete input to work with. Each problem states what to return, how ties and invalid values behave, and which changes would require a different approach.
Keep the reference closed for your first attempt. Produce a solution, walk a small example, explain its cost, then handle the follow-up. The problems reuse the preceding foundations and include separate runnable references for comparison.
Parts group related chapters. Each lesson has a chapter.lesson address, such as 4.07. Open a title below, or use Next to follow the reading sequence. Within a lesson, On this page lists its sections.
- 2.01
Choose a coding problem and work through its contract
Scan and remember
- 2.02
Two sum: remember the useful past
Scan and remember
- 2.03
Valid anagram: equality of multiplicities
Scan and remember
- 2.04
Group anagrams: canonical keys
Scan and remember
- 2.05
Longest unique window: move the boundary forward
Scan and remember
- 2.06
Minimum covering window: track unmet demand
Scan and remember
- 2.07
Count target-sum subarrays: differences of prefixes
Scan and remember
- 2.08
Product except self: combine independent summaries
Scan and remember
- 2.09
Longest consecutive run: expand only from starts
Scan and remember
- 2.10
Merge intervals: preserve the covered set
Order and boundaries
- 2.11
Meeting room capacity: count simultaneous demand
Order and boundaries
- 2.12
Binary search boundary: find the first true position
Order and boundaries
- 2.13
Rotated array search: identify the ordered half
Order and boundaries
- 2.14
Shipping capacity: search a feasible answer
Order and boundaries
- 2.15
Reverse a linked list: keep the unprocessed suffix reachable
Identity and recursion
- 2.16
Find where a linked list loops back on itself
Identity and recursion
- 2.17
Merge sorted lists: splice only a safe frontier
Identity and recursion
- 2.18
Tree level order: keep the next frontier separate
Identity and recursion
- 2.19
Validate a BST: carry every ancestor constraint
Identity and recursion
- 2.20
Lowest common ancestor: return presence as well as a candidate
Identity and recursion
- 2.21
Tree diameter: return one branch, combine two locally
Identity and recursion
- 2.22
Dependency order
Graphs and retained state
- 2.23
Word ladder
Graphs and retained state
- 2.24
Connectivity under added links
Graphs and retained state
- 2.25
Shortest path through a grid
Graphs and retained state
- 2.26
Cheapest route with nonnegative costs
Graphs and retained state
- 2.27
Top k observations in a stream
Graphs and retained state
- 2.28
Merge k sorted streams
Graphs and retained state
- 2.29
Prefix autocomplete
Graphs and retained state
- 2.30
Search for unique combinations
Search and recurrence
- 2.31
Find a word without reusing a cell
Search and recurrence
- 2.32
Minimum coins with a witness
Search and recurrence
- 2.33
Longest increasing subsequence
Search and recurrence
- 2.34
Edit distance
Search and recurrence
- 2.35
Count valid digit decodings
Search and recurrence
- 2.36
Days until a warmer temperature
Stacks, parsing, and streams
- 2.37
Largest rectangle in a histogram
Stacks, parsing, and streams
- 2.38
Parse and evaluate a policy expression
Stacks, parsing, and streams
- 2.39
Maintain an exact streaming median
Stacks, parsing, and streams
- 2.40
Explain algorithm invariants and the changes that invalidate them
Consolidate and assess
- 2.41
Compare coding contracts, return values and complexity
Consolidate and assess
- 2.42
Run an unfamiliar coding mock
Projects and practical assessment
- 2.43
Consume inventory events without counting replays twice
Projects and practical assessment