easy to understand python code

  • 0

    very easy to understand with 39ms
    class Solution(object):
    def removeElement(self, nums, val):
    :type nums: List[int]
    :type val: int
    :rtype: int
    k = 0
    l = len(nums)
    if val not in nums:
    return l
    for i in range(l):
    if nums[i] == val:
    k += 1
    nums[i-k] = nums[i]
    return l-k

Log in to reply

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