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
    [3,2,2,3]
    3
    Your answer
    [3,2]
    Expected answer
    [2,2]

    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.