A python solution


  • 0
    R
    class Solution(object):
        def moveZeroes(self, nums):
            """
            :type nums: List[int]
            :rtype: void Do not return anything, modify nums in-place instead.
            """
            i=0
            t=0
            while t<len(nums):
                if nums[i]==0:
                    nums.pop(i)
                    nums.append(0)
                    t=t+1
                    i=i-1
                else:
                    t=t+1
                i=i+1
            return
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.