3 ms·
I would count the stages of success like this: 1. Brute force it. -> That is actually the most important step. In regards to this one specifically, I would be
by bakuninsbart 7y ago
I would count the stages of success like this:
1. Brute force it. -> That is actually the most important step. In regards to this one specifically, I would be surprised if interviewers expect more than O(n^2).
2. Guess what the best runtime would be. -> If you can reason why you expect what to be the best runtime, it should bring you through all interviews.
3. Get good solutions, but memorizing won't help you in the real world (though it might in some interviews). Interview situation is pretty unique. In a normal work environment, you can search the internet, argue with collegues, sleep over it. If runtime is essential for the program you are writing, it cannot be expected of anyone to come up with best solutions on the fly.
Regarding brute force solutions, they can still vary in quality. Is it correct, easily understandable, without side-effects?