Warm-ups · 11 of 24
Count how often each number appears
Return a list of [value, count] pairs, one per distinct value, sorted by value.
Examples
Input nums = [3, 1, 3, 2, 3, 1]
Output [[1, 2], [2, 1], [3, 3]]
Input nums = []
Output []
📘 New to this? Counting with a hash map explains the idea in a few minutes.