Python solution


  • 0
    A
    class Solution(object):
        def moveZeroes(self, nums):
            """
            :type nums: List[int]
            :rtype: void Do not return anything, modify nums in-place instead.
            """
            j = 0
            for x in nums:
                if x is not 0:
                    nums[j] = x
                    j += 1
                else:
                    pass
            for y in xrange(len(nums)-j):
                nums[j] = 0
                j +=1>! Spoiler
    

Log in to reply
 

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