46. Top K Frequent Elements
MediumArrays & hashing
Return the k most frequent values in nums. Order them by frequency (highest first); break ties by smaller value first.
Example 1
Input: nums = [1, 1, 1, 2, 2, 3], k = 2 Output: [1, 2]
Constraints
1 ≤ k ≤ number of distinct values