class Solution { public: int kthSmallest(vector>& matrix, int k) { std::priority_queue my_pq; int size = matrix.size(); for(int i=0;ik){ my_pq.pop(); } } } // when we get out of the above nested loops, we know the priority queue stores the k smallest elements, and at the top is the largest element among them. return my_pq.top(); } };