Input: [0,1,0,3,12]
Output: [1,3,12,0,0]
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
count = 0
while 0 in nums:
count += 1
nums.remove(0)
nums[:] = nums + [0] * count
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
idx, l, c = 0, len(nums), 0
while idx < l:
if nums[idx] == 0:
nums.remove(nums[idx])
l, c = l - 1, c + 1
else: idx += 1
nums[:] = nums + [0] * c