Loading
Loading
The groundwork for everything else: how to reason about cost, the data structures worth knowing cold, and the handful of techniques that turn a quadratic idea into a linear one. Every chapter ends with the question an interviewer is really asking — what shape is this problem?
Up next: Why Complexity Matters
How to reason about cost before you write code, and why the answer is never measured in seconds.
Why indexing is instant and inserting in the middle is not.
Carrying state through a single pass, and filtering with a write pointer.
Precompute cumulative totals so any range answers in constant time.
Counting occurrences to collapse a nested search into a single pass.
Text as a sequence, the cost of immutability, and the patterns that recur in string problems.
Why building a string in a loop can be quadratic, and what to do instead.
Counting characters, and why a bounded alphabet means constant space.
Transform input into a canonical form so the comparison becomes trivial.
Symmetry as a property of a centre, and a distinction that changes which pattern applies.
The structure behind most quadratic-to-linear improvements, and when it is the wrong tool.
Nodes joined by references, what that makes cheap, and the pointer discipline it demands.
Two ordering disciplines, and the monotonic stack that follows from one of them.