Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
kth smallest element in a matrix
int kthSmallest(int mat[MAX][MAX], int n, int k) { //Your code here priority_queue<int>pq; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { pq.push(mat[i][j]); if(pq.size()>k) { pq.pop(); } } } return pq.top(); }
run
|
edit
|
history
|
help
0
LIS
ExceptionHandling3
iuadhfaoiufs
Using c++11 range-base for loop
a simple tuple implementation
danger73
lifff
Permute
My First Wall
Listas enlazadas - k-esimo elemento