[NeetCode] 169. Majority Element
NeetCode synced attempts for 169. Majority Element.
Tags: algorithms, neetcode, python
Categories: NeetCode
- Problem
- Synced automatically from
devbattery/neetcode-submissions
Notes
Write your own notes here. This section is preserved across syncs.
Attempts
Attempt 1 ยท 2026-04-23 ยท Python
- Commit:
77b24db - Source:
Data Structures & Algorithms/majority-element/submission-0.py
class Solution:
def majorityElement(self, nums: List[int]) -> int:
answer_dict = defaultdict(int)
for num in nums:
answer_dict[num] += 1
return max(answer_dict, key=answer_dict.get)
Leave a comment