Simple Python beats 90%

  • 0

    def moveZeroes(self, nums):
    :type nums: List[int]
    :rtype: void Do not return anything, modify nums in-place instead.
    n = nums.count(0)
    res = [x for x in nums if x != 0]
    nums[:] = res + [0]*n

Log in to reply

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