Simple Python code


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