4 ms·
Yes, I agree with this too. And in some ways sorting is a better solution. The code is certainly simpler. That said, once you point out that you need an effi
by tempestn 12y ago
Yes, I agree with this too. And in some ways sorting is a better solution. The code is certainly simpler. That said, once you point out that you need an efficient solution for large data sets, a competent developer should be able to recognize how to do that. Heck, even if they just said, "ok, so you need to loop through it and keep track of the two largest numbers", then messed up the details, that would be better than most of the answers I've seen. (Again, from people with reasonable-looking applications and resumes.)