Arrays & HashingEasy

Majority Element

One number in nums appears more than half the time. Return it.

Example 1nums = [2, 9, 2] → 2
Example 2nums = [5, 5, 1, 1, 5, 5, 1] → 55 appears 4 times out of 7.
1 ≤ n ≤ 5·10⁴ · a majority always exists

Hints

0 of 3 open
Hint 2 · the patternHint 3 · the key line