why filter(lambda x:x!=val,nums) doesn't work


  • 0
    D
    def removeElement(self, nums, val):
        nums=filter(lambda x:x!=val,nums)
        return len(nums)
    

    why it doesn't work? It said my answer is [3,2] but nums=[2,2]


Log in to reply
 

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