2 line Python easy to understand, but not fast


  • 0
    P
    class Solution(object):
        def removeElement(self, nums, val):
            """
            :type nums: List[int]
            :type val: int
            :rtype: int
            """
            nums.sort( key = lambda x: x==val )
            return len(nums)-nums.count(val)
    

Log in to reply
 

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