Showing:
Handle Score
@Ibrahim Nash 6564
@mb1973 5785
@Quandray 5275
@akhayrutdinov 5111
@saiujwal13083 5074
@kirtidee18 4639
@sanjay05 3762
@mantu_singh 3712
@gfgaccount 3627
@marius_valentin_dragoi 3525
Toppers Of Class
Easy Accuracy: 65.61% Submissions: 285 Points: 2

There is a class of N students and the task is to find the top K marks scorers. You need to print the index of the toppers of the class which will be same as the index of the student in the input array (use 0-based indexing). First print the index of the students having highest marks then the students with second highest and so on. If there are more than one students having same marks then print their indices in ascending order.Suppose k = 2 and the students having highest marks have indices 0 and 5 and students having second highest marks have indices 6 and 7 then output will be 0 5 6 7.

Example 1:

Input:
N=5 K=3
arr[] = { 2, 2, 1, 3, 1 }
Output: 3 0 1
Explanation: Topper with 3 marks is present
at 3rd index, 2 marks is present at 0th
index and next at 1st index.

Example 2:

Input:
N=4 K=1
arr[] = { 1, 2, 3, 4 }
Output: 3
Explanation: The highest marks is at index 3.

Since this is a function problem. You don't need to take any input, as it is already accomplished by the driver code. You just need to complete the function kTop() that takes array A and integer N as parameters and change the given array according to the given conditions. You do not have to return anything

Expected Time Complexity: O(NlogN).
Expected Auxiliary Space: O(1).

Constraints:
1 ≤ N ≤ 106
1 ≤ M ≤ 106