Can anyone please solve this question in python or java [closed]

  c++, java, python

Explaination:

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.

Task:

Your task is to print the integers in the decreasing order of their occurrence in the array.

Note:

• If ri>rj, then ai must be printed before aj.
• If ri==rj, then among ai and aj whichever has a larger value, is printed
first.

Here, ri and rj are the number of repetitions of integers ai and aj in the array.

Note:

Please read the sample explanation carefully to understand the task that you have to perform.

Input format:

• The first line contains an integer N.
• The second line contains N space-separated integers representing the
elements of array a.

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

Source: Windows Questions C++

LEAVE A COMMENT