3 ms·
Thinking about it, it comes down to the level of analysis you choose. If you assume constant space per integer, then it is indeed solvable with O(1) additional
by ckuehne 14y ago
Thinking about it, it comes down to the level of analysis you choose. If you assume constant space per integer, then it is indeed solvable with O(1) additional space. For example, this is usually assumed when analyzing sorting algorithms and I guess this is also what the author had in mind.
- pantaloons 14y agoIf you limit n then than the algorithm is actually O(1) time too -- his answer is wrong either way.