You get an array of integers nums and an integer k. Count how many times each distinct value appears, and return the k distinct values with the highest counts. Each value appears once in the result, however often it occurs in nums.
The result can list the values in any order. The input always has a single right answer: the value ranked k-th by count appears strictly more often than every value left out, so there is never a tie to break at the cut. nums has at least one element, and k is between 1 and the number of distinct values, so the result is never empty.