Wrong answer in Leetcode, but correct in my computer? (Python)

  • 0
        def removeElement(self, nums, val):
            while val in nums:
                nums = nums[:nums.index(val)] + nums[min(len(nums), nums.index(val) + 1):]
            return len(nums)

    Your input
    Your answer
    Expected answer

    But in my computer the new array is [2,2].

Log in to reply

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