Frequencies

L2 Easy Arrays & Hashing
Concept
A frequency dictionary maps each value to how many times it occurred. The default: subscript makes tallying a one-liner.
Return a dictionary that maps each distinct integer in nums to the number of times it appears.
Examples
▸ nums = [1, 2, 1, 3]
→ {1: 2, 2: 1, 3: 1}
▸ nums = []
→ {}
▸ nums = [7]
→ {7: 1}
Progressive Hints
Hint 1 · Nudge
For every distinct number, answer one question: how often did it show up?
Hint 2 · Plan
Create an empty map. For each number, add 1 to its entry, starting a new entry at 0 if the number hasn't been seen yet. Return the filled map.
Hint 3 · Approach
counts = empty map. For each n: counts[n] = counts.getOrDefault(n, 0) + 1. Return counts.
Output
// Run your code to see the output here.