Check whether a list has a majority element

Write codeEasy12 min

Your task

Given a non-empty list nums, return True if any single value occupies strictly more than half of the positions (a strict majority element), otherwise False. For example [3, 3, 4, 2, 3] has 3 appearing 3 of 5 times (>2.5), so return True. The list has at least one element.

Examples

has_majority(nums: list[int]) -> bool
Example 1
Inputhas_majority([3, 3, 4, 2, 3])
OutputTrue