Toppers Of Class
Submissions: 7388   Accuracy:


  Difficulty: Easy   Marks: 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.

The first line of input consists of an integer T denoting the number of test cases .Each test case consists of three lines first line consists of an integer N denoting the number of students of class second line consists N spaced integers denoting the marks of students and third line consists of an integer K which denotes the number of top scores you have to find.

Single line output, denoting the indices of top k cores with space between them.

1 <= T <= 100
1 <= N <= 1000
1 <= marks of students <= 106

It is given that k will be such that its value will always be less than or equal to type of marks of students

2 2 1 3 1
3 0 1

Testcase 1:
Topper with 3 marks is present at 3rd index, 2 marks is present at 0th index and next at 1st index.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Ayush Jha
Author: Ayush jha

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.