From aad4a8dde2a12a8a66c1b8a2b31a8ab7cf1fa34b Mon Sep 17 00:00:00 2001 From: Sk Arman Hossain Date: Mon, 18 Sep 2023 14:12:39 +0000 Subject: [PATCH] Sync LeetCode submission - The K Weakest Rows in a Matrix (cpp) --- .../solution.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 AC-Submissions/problems/the_k_weakest_rows_in_a_matrix/solution.cpp diff --git a/AC-Submissions/problems/the_k_weakest_rows_in_a_matrix/solution.cpp b/AC-Submissions/problems/the_k_weakest_rows_in_a_matrix/solution.cpp new file mode 100644 index 0000000..4da034e --- /dev/null +++ b/AC-Submissions/problems/the_k_weakest_rows_in_a_matrix/solution.cpp @@ -0,0 +1,28 @@ +class Solution { +public: + using int2=pair; + vector kWeakestRows(vector>& mat, int k) { + int n=mat.size(); + priority_queue pq; + for(int i=0; i ans(k, 0); + for(int i=k-1; i>=0; i--){ + ans[i]=pq.top().second; + pq.pop(); + } + return ans; + } +}; \ No newline at end of file