401. Kth Smallest Number in Sorted Matrix
Code ( Language :C++) Edit class Solution { public : /** * @param matrix: a matrix of integers * @param k: An integer * @return: the kth smallest number in the matrix */ struct pqNode { int num; pair< int , int > pos; pqNode( int num, pair< int , int > pos){ this ->num = num; this ->pos = pos; } }; struct cmp { bool operator () (pqNode &n1, pqNode &n2) { return n1.num < n2.num; } }; int kthSmallest ( vector < vector < int >> &matrix, int k) { // write your code here const int m = matrix.size(); if (m == 0 ){ return 0 ; } const int n = matrix[ 0 ].size(); priority_queue<pqNode, vector <pqNode>, cmp> pq; pq.push(pqNode(matrix[ 0 ][ 0 ], { 0 , 0 })); vector < vector < int >> v...