You are given an array a that contains N integers. All the integers in the array may not be distinct.
The number of repetitions of each integer in the array is represented by ri. Your task is to print the integers in the decreasing order of their occurrence in the array.
Note
Here, riand rj are the number of repetitions of integers ai and aj in the array.
Example
Consider an array = [4,4,4,,2,2,1,3,3,1,5] . Now frequencies are :
1 -> 2
2 -> 2
3 -> 2
4 -> 3
5 -> 1
So we have to arrange in the decreasing order of their frequencies . So 4 (1,2,3) 5 . Now we have to take care of numbers having same frequencies . So answer is 4 1 2 3 5 .
Note: Please read the sample explanation carefully to understand the task that you have to perform.
Function description
Complete the solve function provided in the editor. This function takes the following 2 parameters and returns the answer vector sequence :
Input format
Output format
Print the space-separated integers in the decreasing order of their occurrence in the array. The output must be printed in a single line.
Constraints
1≤N≤1000
1≤ai≤1000
In the given sample there are 3 distinct numbers 1 , 2 and 6 with ri values as 2 , 2 and 1. So as per the task given, 2 comes before 1 as it has same ri value but its larger than 1. 1 comes before 6 as its ri value is greater than 6. The output will be
2 1 6