版权声明:@author:geek_aaron https://blog.csdn.net/weixin_39433783/article/details/83010359
注意理解remove和del的区别!!!
(1)remove删除的是首次出现在列表中的元素.
(2)del删除的就是那个索引的元素.
参考代码
class Solution:
def moveZeroes(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
for i in range(len(nums)):
if nums[i] == 0:
nums.remove(nums[i])
nums.append(0)
# return nums