class Solution(object):
def moveZeroes(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
idxs = [idx for idx , num in enumerate(nums) if num == 0]
for i in idxs[::-1]:
nums.pop(i)
nums += len(idxs) *[0]
移动零
最新推荐文章于 2024-03-18 20:55:50 发布