Kth smallest element 

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <queue> #include <algorithm> using namespace std; int main() { // priority_queue<int> maxh; int k; cin>>k; vector<int> A = {7, 10 , 4 ,3 ,20 ,15}; sort(A.begin(), A.end()); cout<<A[k-1]<<endl; } //Above method is by using sorting in STL in O(nlogn) //We can also do this with the help of heap ds in stl;
Editor Settings
Theme
Key bindings
Full width
Lines