Akuna CapitalOA #18
Items Sort
Estimated EasyJudge-ready
Topics (AI-labelled)HashingIn-place Arrays
Sort the values in ascending order of how often each value occurs in the whole array; ties in frequency are broken by ascending value. Equal values keep their original number of occurrences.
Input
The first line contains n; the second line contains n integers items[i]. This site follows the original constraints: 1≤n≤200000, 1≤items[i]≤1000000.
Output
Output the n sorted integers on one line, separated by spaces.
Example 1
Input:
6
4 5 6 5 4 3
Output:
3 6 4 4 5 5
Example 2
Input:
1
9
Output:
9
Example 3
Input:
6
4 4 4 2 2 3
Output:
3 2 2 4 4 4
Editorial
Loading solution…