Dry-Run Three Cases Before You Say Done in a Coding Interview
Saying “done” without a dry run is how correct-looking code fails the last two minutes. Interviewers are not only grading the algorithm. They are grading whether you catch your own bugs without being asked.
The three-case rule
Before you claim finished, walk these out loud while pointing at the code:
- The example they gave — prove you solve the stated problem.
- One boring edge — empty input, single element, all duplicates, already sorted, n = 1.
- The breaker — the input most likely to break your approach (off-by-one, overflow, wrong map key, mutable shared state).
If you cannot invent a breaker, your mental model of the code is still fuzzy. That is the real signal.
How to narrate without sounding robotic
Do not recite a checklist. Tie each case to a line:
- “On the sample
[1,2,2], the counter hits 2 here, then we push…” - “If the array is empty, we return
[]before the loop.” - “If all frequencies are equal, this heap path still returns k items because…”
Touch the code. Interviewers watch your eyes as much as your mouth.
Where people fake the dry run
- Only re-running the happy path
- Skipping empty/single because “obvious”
- Changing code silently mid-check without saying why
- Asking “does this look right?” instead of proving it
Pair it with a finish ritual
A clean ending sounds like:
- Complexity (time/space) in one breath
- Three-case dry run
- One known limitation (“this assumes unique keys; if not, I’d…”)
Then stop talking. Do not keep polishing unless they ask.
Practice under live constraints
In mocks, ban “done” until the three cases are spoken. Record yourself once. You will hear the skips.
If you practice with a live side panel that keeps the question and pad in view while you narrate, tools like Luna Interview can help you stay oriented—use them for rehearsal, not as a crutch that replaces understanding.
Cheat sheet
| Case type | Examples |
|---|---|
| Given | Sample from the prompt |
| Boring edge | [], [x], all same, already sorted |
| Breaker | Max constraints, negatives, ties, Unicode, concurrent mutation |
Unprompted testing is free senior signal. Spend ninety seconds. It often saves the round.
Rehearse with an AI interview copilot, then browse commonly reported interview questions.