one simple python solution


  • 0
    N
    class Solution(object):
        def removeElement(self, nums, val):
            """
            :type nums: List[int]
            :type val: int
            :rtype: int
            """
            l = len(nums)
            i = 0
            while i<l:
                if nums[i]==val:
                    del nums[i]
                    l -= 1
                else:
                    i += 1
            return len(nums)
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.