← 返回 google 的题目列表Bucket Sort / Frequency Sorting
类型:online_judge
Given an integer array nums of length n, return all distinct elements sorted by decreasing frequency. If two elements have the same frequency, sort them by increasing value.
Input (assumed)
Line 1: integer n
Line 2: n integers
Output (assumed)
One line: all distinct elements in the required order, space-separated
Constraints
1 <= n <= 2*10^5
nums[i] fits in 32-bit signed integer
Example Input:
8
1 1 1 2 2 3 3 4
Output:
1 2 3 4
Example
Input
8
1 1 1 2 2 3 3 4
Output
1 2 3 4