Easy to understand python solution


  • 0
    A
    def majorityElement(self, nums):
        numDic = dict(collections.Counter(nums))
        majorityE = 0
        majorityV = 0
        for key in numDic:
            if numDic[key] > majorityV:
                majorityE = key
                majorityV = numDic[key]
        return majorityE

Log in to reply
 

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