Rubber Duck Debugging in a Live Coding Interview

Rubber duck debugging is the old trick of explaining your code, line by line, to an inanimate duck until the bug becomes obvious. In a live coding interview you have something better than a duck: a person who is grading how you think. Used well, the technique finds your bug and earns points while you're stuck.

Why it works

When you read your own code silently, you read what you meant to write. Saying each line out loud forces you to state what it actually does: "this loop runs from 0 to n, inclusive... wait, inclusive?" Off-by-one errors, wrong variable names and inverted conditions tend to surface on the first pass.

A five-step routine for when the output is wrong

  1. Pick the smallest failing input. Not the big example from the prompt: an array of two or three elements, an empty string, a single node.
  2. State the expected result before tracing. "For [3, 1] I expect [1, 3]."
  3. Trace out loud, line by line, writing variable values in a comment or on the side: i=0, j=1, swap? yes.
  4. Stop at the first surprise. The first line where reality diverges from your expectation is where the bug is (or just before it).
  5. Fix one thing, then re-run the same small input. Don't fix three suspected issues at once; you won't know which mattered.

What to say, and what not to

Good: "I expected left to be 2 here but it's 3, so my update must happen too early." That's a hypothesis the interviewer can follow and, often, nudge.

Less good: long silence followed by "hmm, it's broken." Or rapid random edits hoping something sticks. Both hide exactly what the interviewer is trying to evaluate.

Bugs the duck catches most often

Practise it before the interview

When you practise problems alone, debug out loud even though nobody is listening; record yourself once and listen back. It feels awkward the first few times, and it's much better to get past that awkwardness at home than in the interview.


Disclosure: I'm with Linkjob, which builds an AI interview copilot. The routine above needs nothing but a voice.