The problem was Alien Dictionary.
I expected the interviewer to ask about my background in detail, but the interview opened directly with a LeetCode problem. I knew how to solve this one, but I could not write it bug-free. I eventually found that I had indented a break statement in the wrong place. I managed to get my own test to pass before the interview ended, but the interviewer's feedback was not good.
The main issue was that, while checking the code, I did not dry-run it or clearly explain why the next character should be added to the graph only when it is not already there. That check is necessary so its in-degree is not increased twice. The interviewer thought it was a major red flag that I wrote code without explaining it clearly.
I had stayed up studying until 3:30 a.m. and was too tired to react. My brainstorming and verbal approach were all right, but the code was not bug-free. I still need to communicate my thinking clearly with the interviewer before writing code, put my ideas into notes, and only then start solving the problem.
Discussion
Loading comments…