loading…
Write top_k_frequent(nums, k) that returns the k most frequent values, most frequent first. Ties will not affect the answer in the tests.
top_k_frequent([1, 1, 1, 2, 2, 3], 2) -> [1, 2]
Stuck on the idea itself? The arrays & hashing lesson walks through the pattern from scratch.