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 existsOne number in nums appears more than half the time. Return it.