Python. 3 lines. 46 ms

  • 0

    What I consider to be the "pythonic" solution to this problem. It's definitely inefficient to scan nums at each iteration.

    def removeElement(self, nums, val):
        :type nums: List[int]
        :type val: int
        :rtype: int
        while val in nums:
        return len(nums)

Log in to reply

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