Python solution with Counter


  • 0
    A
        def majorityElement(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            return collections.Counter(nums).most_common(1)[0][0]
    

Log in to reply
 

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