2 ms·
If you can't modify the original list, you can create another as you iterate. But that will require extra O(N) memory, so is worse than the textbook solution wi
by pps43 7y ago
If you can't modify the original list, you can create another as you iterate. But that will require extra O(N) memory, so is worse than the textbook solution with two pointers.
- lolc 7y agoInteresting! I didn't know the solution with two pointers and would have assumed O(n) memory as a lower boundary. I must admit I didn't follow the bytecode too closely. So thanks for pointing that out.