Implement `topKFrequent(nums, k)` that returns the `k` most frequent elements. Return them ordered by frequency (highest first); break ties by the smaller value first.
+ 2 hidden tests run on Submit.
A hash map counts occurrences in O(n). Sorting the distinct keys by frequency (then by value to make the order deterministic) and slicing the first k yields the answer. A real interview answer can replace the full sort with a size-k heap for O(n log k).
Run your code to see results.