simple Python sloution


  • 0
    W
    class Solution(object):
        def moveZeroes(self, nums):
            """
            :type nums: List[int]
            :rtype: void Do not return anything, modify nums in-place instead.
            """
            n = len(nums)
            m = 0
            for i in range(n):
                if nums[m] == 0:
                    del nums[m]
                    nums.append(0)
                else:
                    m += 1
            print nums
    

Log in to reply
 

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