Simple Clear Python Solution (46ms or less)

  • 0
    class Solution(object):
        def removeElement(self, nums, val):
            tail = 0
            l = len(nums)
            for i in xrange(l):
                if nums[i] != val:
                    nums[tail] = nums[i]
                    tail += 1
            return tail

Log in to reply

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