Majority Element

L2 Easy Arrays & Hashing
Concept
Once you have a frequency dictionary, "which value is common enough" becomes a direct dictionary scan.
Return the integer that appears more than nums.count / 2 times. If no value is that frequent, return -1.
Examples
▸ nums = [1, 2, 3, 2, 2]
→ 2
▸ nums = [1, 2]
→ -1
▸ nums = [1, 1, 1]
→ 1
Progressive Hints
Hint 1 · Nudge
Find out who shows up more than half the time. You can only know that once you know everyone's tally.
Hint 2 · Plan
Tally every value into a frequency map, then return the first key whose count is greater than half the array size. If none qualifies, return -1.
Hint 3 · Approach
counts = frequency map of nums. For each key: if counts[key] > nums.length / 2 return that key. Otherwise return -1.
Output
// Run your code to see the output here.