解题思路
分析:本题目要求在原数组上进行操作。比较简单,就不赘述了。
代码
class Solution(object): def moveZeroes(self, nums): """ :type nums: List[int] :rtype: None Do not return anything, modify nums in-place instead. """ i,j=0,0 while i<len(nums): if nums[i]==0: j += 1 nums.remove(0) continue i += 1 nums += [0]*j return nums