The complexity follow-up is the cheapest question an interviewer can ask and the most expensive to fumble: 'what's the complexity?' deserves a one-line proof, not a guess. This cheat sheet covers 40 essential complexities — sorting, searching, tree and graph traversals, DP families, hash operations with worst cases, and the amortized analyses (dynamic arrays, union-find) — each with a one-line derivation. Print it, drill it, and never say 'I think it's n log n' again.
This guide walks through big-o cheat sheet: 40 complexities with one-line proofs from first principles: what actually matters, what the incumbents get wrong, and how to set it up in Interview Coder Pro without a developer. Every claim about competitor pricing or limits below reflects the 2026 audit snapshot cited in our comparison hub — verify current numbers on the vendor's own pricing page before you sign anything.
Sorting: quicksort average O(n log n) with O(n^2) worst case (bad pivots), mergesort O(n log n) guaranteed, heapsort O(n log n) in place — one line each on why.
Sorting: quicksort average O(n log n) with O(n^2) worst case (bad pivots), mergesort O(n log n) guaranteed, heapsort O(n log n) in place — one line each on why. In practice, this is where most teams either win or quietly lose: the difference between a tool that earns its place in the workflow and one that gets quietly abandoned after the trial comes down to how deliberately each of these decisions is made.
The complexity follow-up is the cheapest question an interviewer can ask and the most expensive to fumble: 'what's the complexity?' deserves a one-line proof, not a guess. This cheat sheet covers 40 essential complexities — sorting, searching, tree and graph traversals, DP families, hash operations with worst cases, and the amortized analyses (dynamic arrays, union-find) — each with a one-line derivation. Print it, drill it, and never say 'I think it's n log n' again. With Interview Coder Pro, this is handled inside the normal workflow rather than bolted on afterward — configure it once in the workspace, preview the result live, and the telemetry tells you whether it is working. The sections below break the decision into checkable steps.
Hash operations: O(1) average, O(n) worst case under collision attack — the worst-case sentence is what interviewers probe.
Hash operations: O(1) average, O(n) worst case under collision attack — the worst-case sentence is what interviewers probe. In practice, this is where most teams either win or quietly lose: the difference between a tool that earns its place in the workflow and one that gets quietly abandoned after the trial comes down to how deliberately each of these decisions is made.
The complexity follow-up is the cheapest question an interviewer can ask and the most expensive to fumble: 'what's the complexity?' deserves a one-line proof, not a guess. This cheat sheet covers 40 essential complexities — sorting, searching, tree and graph traversals, DP families, hash operations with worst cases, and the amortized analyses (dynamic arrays, union-find) — each with a one-line derivation. Print it, drill it, and never say 'I think it's n log n' again. With Interview Coder Pro, this is handled inside the normal workflow rather than bolted on afterward — configure it once in the workspace, preview the result live, and the telemetry tells you whether it is working. The sections below break the decision into checkable steps.
Tree/graph: DFS/BFS O(V+E) — 'each vertex and edge visited once'; Dijkstra O((V+E) log V) with a binary heap — 'each extraction costs log V'.
Tree/graph: DFS/BFS O(V+E) — 'each vertex and edge visited once'; Dijkstra O((V+E) log V) with a binary heap — 'each extraction costs log V'. In practice, this is where most teams either win or quietly lose: the difference between a tool that earns its place in the workflow and one that gets quietly abandoned after the trial comes down to how deliberately each of these decisions is made.
The complexity follow-up is the cheapest question an interviewer can ask and the most expensive to fumble: 'what's the complexity?' deserves a one-line proof, not a guess. This cheat sheet covers 40 essential complexities — sorting, searching, tree and graph traversals, DP families, hash operations with worst cases, and the amortized analyses (dynamic arrays, union-find) — each with a one-line derivation. Print it, drill it, and never say 'I think it's n log n' again. With Interview Coder Pro, this is handled inside the normal workflow rather than bolted on afterward — configure it once in the workspace, preview the result live, and the telemetry tells you whether it is working. The sections below break the decision into checkable steps.
DP: complexity is states × transition cost — 'n states, O(1) per transition' derives every DP bound you will ever state.
DP: complexity is states × transition cost — 'n states, O(1) per transition' derives every DP bound you will ever state. In practice, this is where most teams either win or quietly lose: the difference between a tool that earns its place in the workflow and one that gets quietly abandoned after the trial comes down to how deliberately each of these decisions is made.
The complexity follow-up is the cheapest question an interviewer can ask and the most expensive to fumble: 'what's the complexity?' deserves a one-line proof, not a guess. This cheat sheet covers 40 essential complexities — sorting, searching, tree and graph traversals, DP families, hash operations with worst cases, and the amortized analyses (dynamic arrays, union-find) — each with a one-line derivation. Print it, drill it, and never say 'I think it's n log n' again. With Interview Coder Pro, this is handled inside the normal workflow rather than bolted on afterward — configure it once in the workspace, preview the result live, and the telemetry tells you whether it is working. The sections below break the decision into checkable steps.
Amortized: dynamic array append O(1) amortized ('doubling means n appends cost O(n) total'); union-find near-O(1) with path compression and union by rank.
Amortized: dynamic array append O(1) amortized ('doubling means n appends cost O(n) total'); union-find near-O(1) with path compression and union by rank. In practice, this is where most teams either win or quietly lose: the difference between a tool that earns its place in the workflow and one that gets quietly abandoned after the trial comes down to how deliberately each of these decisions is made.
The complexity follow-up is the cheapest question an interviewer can ask and the most expensive to fumble: 'what's the complexity?' deserves a one-line proof, not a guess. This cheat sheet covers 40 essential complexities — sorting, searching, tree and graph traversals, DP families, hash operations with worst cases, and the amortized analyses (dynamic arrays, union-find) — each with a one-line derivation. Print it, drill it, and never say 'I think it's n log n' again. With Interview Coder Pro, this is handled inside the normal workflow rather than bolted on afterward — configure it once in the workspace, preview the result live, and the telemetry tells you whether it is working. The sections below break the decision into checkable steps.
Frequently asked questions
How do I prove a complexity in one line?
Count what the algorithm touches: 'each element visited once' → O(n); 'halved each step' → O(log n); 'n states × O(1) transitions' → O(n). The proof is the counting argument, stated plainly.
What complexity mistakes do candidates make?
Three: confusing worst and average case (quicksort), forgetting the sort inside the solution (that O(n log n) you hid), and ignoring space (the hash map is O(n) too). State all three explicitly.
Do interviewers really ask for proofs?
They ask 'why?' — which is a proof request. 'Because each level halves' is a proof. You do not need formalism; you need the counting argument.
How should I drill this?
The pattern library pairs every pattern with its complexity and proof sketch; the complexity analyzer generates proof sketches for your own solutions. Drill until the one-liners are automatic.