Pick the fix
You realise halfway through that your approach misses a case. What is the best move?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Say what you found, show the failing example, and explain the fix before changing code
Right: it shows testing and judgement, and lets the interviewer follow.
Catching your own bug out loud usually scores better than code that was right first time but never explained.
Why not the others?
- B Quietly rewrite the function. The interviewer cannot see your reasoning.
- C Carry on and hope it is not noticed. Interviewers usually test exactly those cases.