Skip to content

Instantly share code, notes, and snippets.

@tamlt2704
Created December 31, 2017 11:36
Show Gist options
  • Select an option

  • Save tamlt2704/e16b69e8b3f74f14bde3f52c025e6e9c to your computer and use it in GitHub Desktop.

Select an option

Save tamlt2704/e16b69e8b3f74f14bde3f52c025e6e9c to your computer and use it in GitHub Desktop.
#https://leetcode.com/problems/move-zeroes/description/
class Solution(object):
def moveZeroes(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
zero = 0
for i in xrange(0, len(nums)):
if nums[i] != 0:
nums[i], nums[zero] = nums[zero], nums[i]
zero += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment