#coding=utf-8
# 解题思路:无 20190302 找工作期间
class Solution(object):
def moveZeroes(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
if nums == None:
return None
k = 0
for i in range(len(nums)):
if nums[i] != 0 :
nums[k] = nums[i]
k = k+1
while k <= i:
nums[k] = 0
k = k+1
return nums
class Solution2(object):
def moveZeroes(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
if nums == None:
return None
k = 0
for i in range(len(nums)):
if nums[i] != 0 :
temp = nums[k]
nums[k] = nums[i]
nums[i] =temp
k = k+1
return nums
n = [0,1,0,3,12]
s = Solution2()
n1 =s.moveZeroes(n)
print n1