Build the PrimitiveMedium
Top K Frequent Elements
Write `top_k_frequent(nums, k)` returning the `k` most frequent values, in any order.
top_k_frequent([1, 1, 1, 2, 2, 3], 2) -> [1, 2]
Sorting by count is O(n log n) and a size-k heap is O(n log k). Both are accepted; neither is the best. A frequency can never exceed the length of the list, so counts can be bucketed into an array indexed by frequency and read from the top — O(n). Reach for that one and say why it is available here.
What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.