题目描述
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.
Note that it is the kth smallest element in the sorted order, not the kth distinct element.
Example:
1 | matrix = [ |
这题我想不到什么更好的方法,并没有用到行列之间的有序性来做,只是维持了一个最大堆(优先序列)去做,不过OJ还是可以通过的。
代码实现
1 | class Solution { |