Simple python solution


  • 0
    V

    Nearly the same method with the optimal answer of C++
    '''
    j=0
    for i in range(len(nums)):
    if nums[i]!=0:
    nums[i],nums[j]= nums[j],nums[i]
    j+=1
    '''


Log in to reply
 

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