Given an integer array nums and an integer k, return the k most frequent elements. You may return them in any order.
Input: nums = [1, 1, 1, 2, 2, 3], k = 2 Output: [1, 2] Explanation: 1 appears 3 times and 2 appears 2 times - the two most frequent.
Input: nums = [1], k = 1 Output: [1] Explanation: There is only one element, which is trivially the most frequent.
nums = [1, 1, 1, 2, 2, 3], k = 2