Sorting, and why the numbers are distinct!
The description of problems always brings important information - it is rare that an information inside the problem description doesn't add any value. For instance, in this problem all the scores are unique. This is done so that you can create a unique mapping score --> row which can be used to reconstruct the matrix after the sorting is completed. Hence you can complete the task in O(row*col + row*log(row))-time and O(row*col)-space. Code is down below, cheers, ACC. Sort the Students by Their Kth Score - LeetCode 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 i th student got in the j th exam. The matrix score contains distinct integers only. You are also given an integer k . Sort the students (i.e., the rows of the matrix) by their scores in...