Simple python solution 36ms


  • 0
    G

    class Solution(object):
    def removeElement(self, nums, val):
    """
    :type nums: List[int]
    :type val: int
    :rtype: int
    """
    a=0
    for number in nums:
    if number==val:
    a+=1
    for j in range(a):
    nums.remove(val)
    return(len(nums))


Log in to reply
 

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