Leetcode 283 Move Zeroes python

题目:

Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.

For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0].

python中没有自增运算符++.

 class Solution(object):
def moveZeroes(self, nums):
index =
size = len(nums)
for i in range(size):
if nums[i] == :
continue
else:
nums[index] = nums[i]
index +=
while index < size:
nums[index] =
index +=
上一篇:Java [Leetcode 283]Move Zeroes


下一篇:JavaScript小实例:拖拽应用(二)