All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 24, 2024
Last updated : June 24, 2024
Related Topics : Array, Sorting, Matrix
Acceptance Rate : 85.59 %
class Solution {
public int[][] sortTheStudents(int[][] score, int k) {
Arrays.sort(score, new Comparator<int[]>() {
public int compare(int[] a, int[] b) {
return -1 * Integer.compare(a[k], b[k]);
}
});
return score;
}
}
class Solution:
def sortTheStudents(self, score: List[List[int]], k: int) -> List[List[int]]:
return sorted(score, key=lambda x: x[k], reverse=True)