题解 | #移动 0#

移动 0

http://www.nowcoder.com/practice/102586387caa4afcbad6f96affce9780

#啊这啊这,直接遍历,遇到0 remove删除,后在列表尾append

class Solution:
    def moveZeroes(self , nums: List[int]) -> List[int]:
        # write code here
        for i in nums:
            if i==0:
                nums.remove(i)
                nums.append(0)
        return nums
全部评论
大佬,麻烦看下,NC286那道题用同样的方法为啥不行啊?
点赞
送花
回复
分享
发布于 2022-12-14 18:00 北京

相关推荐

点赞 评论 收藏
转发
2 收藏 评论
分享
牛客网
牛客企业服务