Twenty Minutes In

Forty-five minute round. At minute 20 you have a correct, tested O(n2)O(n^2) solution on the screen and you have just seen how a sorted scan would make it O(nlog⁡n)O(n \log n). You estimate the rewrite at 15 minutes and you are not certain of the edge cases.

What is the strongest move?

A

Keep the O(n2)O(n^2) on screen and quietly refactor it toward the faster version, so that whichever one you land on looks like the plan all along.

B

Say what you have, name the O(nlog⁡n)O(n \log n) idea and the one step you are unsure about, state your estimate, and ask whether the interviewer would rather see it implemented or discussed. Then do what they say.

C

Start the rewrite immediately. The optimal solution is what is being scored, and 25 minutes is enough.

D

Leave the O(n2)O(n^2) and say nothing more about it. Declaring an improvement you did not write only draws attention to what you did not finish.