leetcode169 python3 92ms 求众数
class Solution:
def majorityElement(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
freq = {}
for i in nums:
if i not in freq.keys():
freq[i] = 1
else:
freq[i] += 1
if freq[i] > len(nums)//2:
return i