Update appNew update is available. Click here to update.
sidenav-btnClose
Topic list
Iruka And Marks
EASY
Strings
Sorting
Arrays
Topics (Covered in this problem)
Problem solved
Badge
Skill meter
Strings
-
-
Sorting
-
-
Arrays
-
-
Other topics
Problem solved
Badge
Skill meter
Matrices (2D Arrays)
-
-
Linked List
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
userLevel
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

Iruka And Marks

Contributed by
Akhilesh Singh Bhadauria
Easy
yellow-spark
0/40
Share
0 upvotes

Problem Statement

Iruka Umino is the instructor at the shinobi school at Konoha. He took a test of all the students in his class and evaluated their answer sheets on a grade of 100. He has ‘N’ number of students in his class.

You are given an ‘N’ and then you are provided with ‘N’ students with their names and marks.

You have to organize the list of students in such a way that students with higher marks come first and in the case of students with equal marks, the student with lexicographically smaller names comes first.

Example:-
Input: ‘N’ = 3, ‘STUDENTS’ = [[‘naruto’, 50], [‘sasuke’, 95], [‘sakura’, 65]]

Output: [[‘sasuke’, 95], [‘sakura’, 65], [‘naruto’, 50]]

In the example above you can see that ‘sasuke’ got the highest marks so he came first in the output followed by ‘sakura’ and ‘naruto’ with the lowest marks.
Detailed explanation ( Input/output format, Notes, Constraints, Images )
Sample Input 1 :
2
3
naruto 50
sakura 65
sasuke 95
2
kiba 70
shikamaru 78
Sample Output 1 :
sasuke 95
sakura 65
naruto 50
shikamaru 78
kiba 70
Explanation Of Sample Input 1 :
For the first case:-
You can see that ‘sasuke’ got the highest marks so he came first in the output followed by ‘sakura’ and ‘naruto’ with the lowest marks.

For the second case-
Here ‘shikamaru’ got 78 marks greater than 70 so he comes first followed by ‘kiba’ with 70 marks.
Sample Input 2 :
2
5
minato 92
sakumo 87
itachi 99
madara 92
ino 80
3
minato 90
madara 90
hiruzen 90
Sample Output 2 :
itachi 99
madara 92
minato 92
sakumo 87
ino 80
hiruzen 90
madara 90
minato 90
Reset Code
Full screen
Auto
copy-code
Console