My simple python solution (3 lines)

  • 0
    class Solution(object):
        def removeElement(self, nums, val):
            while val in nums:
            return len(nums)

  • 0

    Wow, the test cases are weak. They should include something like this:

    nums = [0] * 5000 + [1] * 5000
    val = 1

    Takes over 2 seconds on my PC (a fast solution I have takes about 0.002 seconds for it).

Log in to reply

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