问题描述:
![](https://img.haomeiwen.com/i6315044/4c6599fdf88017df.png)
代码示例:
class Solution(object):
def moveZeroes(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
n = len(nums)
count = 0 #count记录数组中不为0的元素的个数
for value in nums:
if value != 0:
nums[count] = value
count += 1
for i in range(count,n):
nums[i] = 0
网友评论