One-line python code using Counter


  • 0
    S
    from collections import Counter
    
    class Solution(object):
        def singleNumber(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            return Counter(nums).most_common()[-1][0]
    

Log in to reply
 

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