283. Move Zeroes

来源:互联网 发布:python ffmpeg 库安装 编辑:程序博客网 时间:2024/06/06 05:26
class Solution(object):
    def moveZeroes(self, nums):
        """
        :type nums: List[int]
        :rtype: void Do not return anything, modify nums in-place instead.
        """
        tmp=0
        for i in range(len(nums)):
            if nums[i]!=0:
                nums[tmp]=nums[i]
                tmp+=1
        for i in range(tmp,len(nums)):
            nums[i]=0