nums appears exactly twice, except for one integer that appears only once. Find and return that unique integer.Find the Lone Number
L2 Easy Arrays & Hashing
Concept
Frequency analysis makes "which one is odd one out?" mechanical: find the entry whose count looks different from every other.
Every integer in
Examples
▸ nums = [2, 2, 3, 3, 4]
→ 4
▸ nums = [1]
→ 1
▸ nums = [5, 7, 5, 9, 7]
→ 9
Progressive Hints
Hint 1 · Nudge
Everyone has a matching partner except one. Find the odd one out by tallying the pairs.
Hint 2 · Plan
Tally how often each value appears, then return the key whose tally is exactly 1.
Hint 3 · Approach
counts = frequency map. For each key: if counts[key] == 1 return that key.
All hints are out. Take a breath and give it a shot.
Output
// Run your code to see the output here.