Move Zeroes
Push every zero to the end in place, keeping the other numbers in order, with a write pointer and a read pointer.
01The problem
Move all 0s in nums to the end in place (no new array), keeping the non-zero numbers in their original order.
| Input | Output |
|---|---|
[0, 1, 0, 3, 12] | [1, 3, 12, 0, 0] |
[0] | [0] |
Loading the rest of the lesson…