My Python Solution


  • 0
    W
    class Solution(object):
        def moveZeroes(self, nums):
            j = 0
            for n in nums:
                if n != 0:
                    nums[j] = n
                    j += 1
            while j < len(nums):
                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.