169. Majority Element
Easy
π Solution
class Solution:
def majorityElement(self, nums: List[int]) -> int:
temp = {}
for n in nums:
if n in temp:
temp[n] += 1
else:
temp[n] = 1
majority = int(len(nums)/2)
for n,count in temp.items():
if count > majority:
return nLast updated