Find the k most frequent integers in a list using a heap-based approach.
Constraints
Example
```python >>> top_k_frequent([1,1,1,2,2,3], 2) [1, 2] >>> top_k_frequent([1], 1) [1] >>> top_k_frequent([4,4,4,4], 1) [4] >>> top_k_frequent([6,5,4,3,2,1], 3) [6, 5, 4] # all frequency 1, descending value >>> top_k_frequent([1,1,2,2,3,3], 2) [3, 2] # tie on frequency, larger value first ```
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints