Class Solution
- java.lang.Object
-
- g2501_2600.s2545_sort_the_students_by_their_kth_score.Solution
-
public class Solution extends Object
2545 - Sort the Students by Their Kth Score.Medium
There is a class with
mstudents andnexams. You are given a 0-indexedm x ninteger matrixscore, where each row represents one student andscore[i][j]denotes the score theithstudent got in thejthexam. The matrixscorecontains distinct integers only.You are also given an integer
k. Sort the students (i.e., the rows of the matrix) by their scores in thekth( 0-indexed ) exam from the highest to the lowest.Return the matrix after sorting it.
Example 1:

Input: score = [[10,6,9,1],[7,5,11,2],[4,8,3,15]], k = 2
Output: [[7,5,11,2],[10,6,9,1],[4,8,3,15]]
Explanation: In the above diagram, S denotes the student, while E denotes the exam.
-
The student with index 1 scored 11 in exam 2, which is the highest score, so they got first place.
-
The student with index 0 scored 9 in exam 2, which is the second highest score, so they got second place.
-
The student with index 2 scored 3 in exam 2, which is the lowest score, so they got third place.
Example 2:

Input: score = [[3,4],[5,6]], k = 0
Output: [[5,6],[3,4]]
Explanation: In the above diagram, S denotes the student, while E denotes the exam.
-
The student with index 1 scored 5 in exam 0, which is the highest score, so they got first place.
-
The student with index 0 scored 3 in exam 0, which is the lowest score, so they got second place.
Constraints:
m == score.lengthn == score[i].length1 <= m, n <= 2501 <= score[i][j] <= 105scoreconsists of distinct integers.0 <= k < n
-
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[][]sortTheStudents(int[][] score, int k)
-