Given a list of numbers nums and a number k, return the k values that appear most often in nums. For example, think of the k most ordered dishes in a list of orders. You may return the answer in any order.
Examples
Example 1:
Input: nums = [4,4,4,7,7,9], k = 2
Output: [4,7]
Explanation: 4 appears 3 times, 7 appears 2 times, 9 appears once. The two most frequent are 4 and 7.
Example 2:
Input: nums = [5,5,5,3,3,8,8,8,8], k = 1
Output: [8]
Explanation: 8 appears 4 times, more than any other value.
Example 3:
Input: nums = [3,3,9,9,5], k = 2
Output: [3,9]
Explanation: 3 and 9 appear twice each, and 5 appears once.