Move Zeroes
EasyTwo Pointers
Decode it first. Clues, constraints, pattern and plan before any code.Given a list of integers nums, move every 0 to the end in place, keeping the non-zero values in their original relative order. Do not return anything and do not build a new list: change nums itself.
nums = [0, 1, 0, 3, 12] → nums becomes [1, 3, 12, 0, 0]
nums = [0] → nums stays [0]
nums = [4, 0, 5] → nums becomes [4, 5, 0]Constraints
0 <= nums.length <= 10^4-2^31 <= nums[i] <= 2^31 - 1- Use O(1) extra space.