One Line Python Solution


  • 2

    because the question assume the majority string always exist, we have

     def majorityElement(self, nums):
            return sorted(collections.Counter(nums),key=collections.Counter(nums).__getitem__, reverse = True)[0]
    

Log in to reply
 

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