2 ms·
> This often trips up people who don't know how big O works They didn't ask for an algorithm with linear complexity. They explicitly asked for a solution "in o
by tralarpa 8y ago
> This often trips up people who don't know how big O works
They didn't ask for an algorithm with linear complexity. They explicitly asked for a solution "in one pass". That's highly misleading.
Edit (after the reply by zamalek): And you are perfectly right about the performance: it's probably slower than just doing two passes (one to find the length, the second to find the middle).
- zamalek 8y agoAs the root comment points out, both solutions (the second being two loops) are 1.5 passes.