EricssonOA #2
Top K Frequent Elements
估计中等可在线判题
Output the k most frequent elements, sorted by frequency in descending order and then by value in ascending order.
The standard input/output conventions and constraints added by this site are given under "Input".
输入格式
n≤100000, −10000≤x≤10000, 1≤k≤distinct. The input contains n k followed by the array.
输出格式
Output k integers.
样例 1
输入:
6 2
1 1 1 2 2 3
输出:
1 2
样例 2
输入:
5 5
4 5 2 1 3
输出:
1 2 3 4 5
样例 3
输入:
5 2
-1 -1 2 2 0
输出:
-1 2