Python solution that works on my computer but not on the website


  • 0
    K
    def removeElement(self, nums, val):
            copy = list(nums)
            for each in nums:
                if each == val:
                    copy.remove(val)
            return len(copy)
    

    Could anyone help me find the bug?


  • 0
    L

    Remove the elements in place; don't make a copy and remove the elements from the copy.


Log in to reply
 

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