Leetcode/python/169_majority_element.py

4 lines
136 B
Python
Raw Normal View History

2024-04-30 16:11:48 +00:00
class Solution:
def majorityElement(self, nums: List[int]) -> int:
return max(Counter(nums).items(), key=lambda k: k[1])[0]