def moveZeroes(nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ for i in nums: if i == 0: nums.remove(i) nums.append(0)
because the length of nums won't change, my iteration will execute exactly len(nums) times.
Remove is O(n). Total complexity is O(n^2).