27.Remove Element

 

 

 

class Solution:
    def removeElement(self, nums: List[int], val: int) -> int:
        j = 0
        for i, v in enumerate(nums):
            if v != val:
                nums[j] = v
                j += 1
        return j

 

posted @ 2020-05-09 15:21  星海寻梦233  阅读(96)  评论(0编辑  收藏  举报