27,移除元素

class Solution:
    def removeElement(self, nums: List[int], val: int) -> int:
        i = len(nums)-1
        while i >= 0:
            if nums[i] == val:
                nums.pop(i)
            i -= 1
        return len(nums)

猜你喜欢

转载自blog.csdn.net/weixin_42758299/article/details/88630801
今日推荐