It's OK to Make Mistakes in Coding Interviews
Imagine you’re an interviewer in a software engineering interview. The interviewee writes a method and it’s completely wrong. They go on to implement other parts of the problem, then later realize there’s a bug and come back and fix the original method.
One thing that isn’t super clear for both interview candidates and interviewers is how to treat mistakes like this. The candidate definitely made a mistake. But their final implementation is correct. Should they be penalized?
The answer is almost certainly no. As an interview candidate you will come across interviewers who expect perfect, impeccably flawless code to flow out the second your marker hits the whiteboard. But most interviewers I know would not penalize a coding mistake if you eventually catch it.
Additionally this can be a more positive signal than writing perfect code in the first place. If a candidate writes perfect code with no mistakes, it leaves you wondering, have they seen this solution before? Every programmer makes mistakes (unless you’re Jeff Dean). I believe demonstrating that you can revisit your code and catch and correct bugs can only give more positive signal to your interviewer.