1. Given an array A[] of integers, sort the array according to frequency of elements.
2. Elements that have higher frequency come first.
3. If frequencies of two elements are same, then smaller number comes first.
Input Format
The first line of each test case contains a single integer N denoting the size of array. The second line contains N space-separated integers denoting the elements of the array.
Output Format
Return the frequency sorted array.
Constraints
N<10^4
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
5 5 5 4 6 4
Output
4 4 5 5 6