My python3 solution


  • 0
    Y
    class Solution(object):
        def removeElement(self, nums, val):
            """
            :type nums: List[int]
            :type val: int
            :rtype: int
            """
            if not len(nums):
                return 0
            i = 0
            for j in range(len(nums)):
                if nums[j] == val:
                    continue
                else:
                    nums[i] = nums[j]
                    i += 1
            return i
    

Log in to reply
 

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