Geeksforgeeks

Error

×

Geek hosted a contest and **N** students participated in it. The score of each student is given by an integer array **arr[]**. The task is to print the number of each student (indexes) in the order they appear on the scoreboard.

A student with a maximum score appears first. If two people have the same score then a higher indexed student appears first.

**Example 1:**

**Input:
**N = 5
arr[] = {450, 230, 730, 230, 150}
**Output:
**3 1 4 2 5
**Explanation:
**1. The top scorer is at 3^{rd} index, therefore 3
at the first index.
2. The second-highest scorer is at 1^{st} index therefore
1 is at the second index.
3. The third-highest scorer is at 4^{th} index therefore
4 at the thirst index.

**Example 2:**

**Input:
**N = 3
arr[] = {500, 500, 500}
**Output:
**3 2 1

**Your Task:**

This is a full problem. You need to write the complete code.

1. The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.

2. The first line of each test case contains a single integer N.

3. The next line contains N space-separated integers.

**Expected Time Complexity: **O(NlogN).

**Expected Auxiliary Space: **O(N).

**Constraints:**

2 ≤ N ≤ 10^{5}

1 ≤ cost[i] ≤ 10^{4}

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Geek and Contest ||

...