Medium · Arrays & hashing
Top K Frequent Elements
You are given a list of whole numbers, nums, and a number, k. Return the k different values that appear most often.
- The answer can be in any order.
- k is at least 1 and never more than the number of different values.
- There is one clear answer: no tie at the cut-off.
nums = [1, 1, 1, 2, 2, 3], k = 2 → [1, 2] (1 appears three times, 2 twice)Record your take