Guide · coding-prep
How to Recover from a Wrong Solution Mid-Interview
Catching your own wrong answer out loud is a stronger signal than getting it right the first time. State the bug clearly, propose the fix, and rewrite — don't apologize. The interviewer is grading your recovery, and recovery is half the rubric.
By Alex Chen, Founder, InterviewChamp.AI · Last updated
How do you recover from a wrong solution mid-interview?
Three moves: stop typing, name the bug out loud, and propose the fix in one sentence before re-coding. Don't apologize, don't restart silently, and don't pretend it's still working. Self-correction under pressure is one of the highest-graded signals on coding-interview rubrics — sometimes higher than a clean first-try solution. Recovery is the rubric.
The 30-second recovery script
When you realize your solution is wrong (or the interviewer points it out), run this exact sequence:
Second 1-5 — Stop and acknowledge. "Wait. Let me look at this." Say it out loud. Stop typing. You can't think and type at the same time, and the interviewer needs to see you switch modes from production to debugging.
Second 5-15 — Name the bug. "The issue is that when there are duplicates, the hash map overwrites the earlier index, so I lose the first occurrence." Specific. Falsifiable. The interviewer can now grade your diagnosis.
Second 15-25 — Propose the fix. "I think if I switch the value from a single index to a list of indices, that handles it without changing the time complexity." Now you've shown the recovery has a destination, not just a problem.
Second 25-30 — Verify direction before re-coding. "Does that approach make sense, or are you seeing a simpler fix?" One short check. Then code.
The whole thing takes thirty seconds and reads as engineering. Compare that to silently deleting code, re-typing, and hoping the interviewer didn't notice — which is what most new grads do and is almost always graded down.
Why apologizing hurts more than the bug
The instinct is to say "sorry, I should have seen that." Don't. It signals you think the bug is shameful (which makes the interviewer wonder how you'd act on a real team where bugs are constant), it eats time you should spend fixing, and it shifts the frame from "engineer at work" to "candidate being judged." Per the Pragmatic Engineer's writing on interview feedback patterns, candidates who say "good catch, let me fix it" significantly outperform candidates who say "I'm so sorry, I can't believe I missed that" — even when the underlying mistake and fix are identical.
When to fix vs when to scrap
Some bugs are local — a missing edge case, an off-by-one, a wrong comparison operator. Fix in place. State the fix, change two lines, move on.
Other bugs are architectural — your data structure can't represent what the problem needs, or your loop direction is wrong. Scrap.
The test: can you describe the fix in one sentence without restating the algorithm? If yes, fix in place. If you find yourself saying "well, if I changed the data structure, then I'd also need to change…" you're really doing a scrap. Announce it:
"My current approach can't handle case X without significant restructuring. I think a [different structure] handles it cleanly. Let me restart with that — should take about five minutes."
One scrap and restart is normal. Per Indeed Career Guide research on technical interview signals, the candidates who recovered from a complete restart inside a 45-minute coding round received "hire" or "strong hire" recommendations at a rate not statistically different from candidates whose first solution worked.
How to handle the interviewer catching your bug
If they catch it before you do, the playbook is:
- Acknowledge briefly: "You're right, let me check." No "oh no" or "ugh."
- Trace through it on the spot: "If the input is
[1,1,2], my code returns 1 instead of 0. So yes, duplicates break it." - Diagnose out loud: "The bug is in the inner condition — I'm checking
==when I should be checking<." - Fix: Change the line, re-trace the small example, confirm.
- Thank them once, briefly: "Thanks for that — good check." Then move on.
What kills candidates here is defensiveness. "Are you sure?" "Hmm, I think mine works…" Even if you're 80% sure they're wrong, run their counter-example. If your code does survive, say "I traced through [1,1,2] and it returned 0 — am I missing what you meant?" Calm verification beats defensive pushback every time.
Recovery is a learned skill. The drill: pick a problem you've solved cleanly, then re-solve it knowing you'll introduce a bug halfway through. Practice catching it on a small example, naming it, and fixing it — all out loud. Don't pre-script the answer; script the shape of the response. The candidates who win recovery moments have rehearsed the shape so often that it runs even under stress.
About the author: Alex Chen is the founder of InterviewChamp.AI and writes about the modern tech interview from the inside — what changed, what works for new grads, and where the old playbook fails.
Frequently asked questions
- Will catching a wrong solution mid-interview hurt my chances?
- Usually the opposite. Self-correction is one of the most positively-graded signals on tech interview rubrics. Catching your own bug calmly often scores higher than a solution that worked the first time, because it proves you can debug — which is what the job actually requires.
- What should I do the moment I realize my solution is wrong?
- Say it out loud immediately. 'Wait — this fails when the input has duplicates. Let me trace through.' Don't keep typing in hope. The longer you push a known-wrong solution, the worse it looks. Pause, name the bug, propose the fix.
- What if the interviewer caught the bug before I did?
- Thank them briefly, then own the fix. Don't get defensive. 'Good catch — let me trace through what I missed.' Then actually trace it. Interviewers want to see how you take feedback under pressure; defensive responses tank that signal.
- Is it ever okay to scrap the solution and start over?
- Yes — but announce it. 'My approach doesn't actually work for case X. I think a different structure handles this — let me switch to that.' One scrap and restart is fine. Two is a yellow flag. Three usually means the problem wasn't understood in the first place.
- What if I'm not sure whether my solution is actually wrong?
- Trace through a small adversarial example. Pick the case most likely to break your solution (empty input, duplicates, single element, sorted-descending). If it works, you're fine. If it breaks, you've found the bug yourself — which is the best possible outcome.