One Python solution

  • 0

    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
    for y in xrange(len(nums)-j):
    nums[j] = 0
    j +=1

Log in to reply

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