https://leetcode.com/problems/sort-the-students-by-their-kth-score/description/
Sort the Students by Their Kth Score - LeetCode
Sort the Students by Their Kth Score - There is a class with m students and n exams. You are given a 0-indexed m x n integer matrix score, where each row represents one student and score[i][j] denotes the score the ith student got in the jth exam. The matr
leetcode.com
1
2
3
|
class Solution:
def sortTheStudents(self, score: List[List[int]], k: int) -> List[List[int]]:
return sorted(score, key= lambda x: -x[k])
|
cs |
lambda를 활용해서 정렬해주시면 쉽게 됩니다
큰 순서대로 정렬해야하니까 x[k] 앞에 마이너스를 붙입니다
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 196. Delete Duplicate Emails (0) | 2023.01.29 |
---|---|
leetcode 2433. Find The Original Array of Prefix Xor (0) | 2023.01.27 |
leetcode 2396. Strictly Palindromic Number (0) | 2023.01.27 |
leetcode 1689. Partitioning Into Minimum Number Of Deci-Binary Numbers (0) | 2023.01.26 |
codeforces 50A - Domino piling (0) | 2023.01.25 |
댓글