• 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

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