My python3 solution


  • 0
    Y
    class Solution(object):
        def moveZeroes(self, nums):
            """
            :type nums: List[int]
            :rtype: void Do not return anything, modify nums in-place instead.
            """
            if not nums:
                return
            index = 0
            for item in nums:
                if item:
                    nums[index] = item
                    index += 1
                else:
                    continue
            nums[index:] = [0] * (len(nums) - index)
    

Log in to reply
 

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