def moveZeroes(self, nums):
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
numOfZero = nums.count(0) n = len(nums) if numOfZero == len(nums) or numOfZero == 0: return for i in range(n): if nums[i] == 0: del nums[i] for i in range(numOfZero): nums.append(0)
Modifying a list while iterating over it. This is what called accidental-deletion-of-a-list-item-while-iterating-over-it bug. You can try
nums[:] = [n for n in nums if n] to move zeros from nums
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.