Interview Budget Time

It is better to explain your thought process before just jumping into coding. I would say maybe like 1 - 5 minutes depending on the difficulty of the problem, how comfortable you are with the problem, and the feedback of your interviewer, then start coding. You can also write pseudocode at this step, or maybe draw a diagram if you are whiteboarding.

Mention possible approaches and their strengths/drawbacks/time complexity/space complexity. Even if you know the optimal algorithm, it will usually be better to quickly mention the brute force approach and state its time complexity, then explain that you have a better approach.

If you are unsure of the optimal solution, brainstorm a bit and do your best to come with at least a brute force approach. Do your best to give the runtime and try to gauge if the interviewer wants you to code up that approach or if they want to you think a bit longer and get something closer to the optimal solution.

/r/csMajors Thread