diff --git a/Kth_Largest_Element_in_an_Array.cpp b/Kth_Largest_Element_in_an_Array.cpp new file mode 100644 index 0000000..1636d92 --- /dev/null +++ b/Kth_Largest_Element_in_an_Array.cpp @@ -0,0 +1,15 @@ +public: + int findKthLargest(vector& nums, int k) { + priority_queue pq; + for(auto i : nums){ + pq.push(i); + } + int i = 1; + while(i!=k){ + pq.pop(); + i++; + } + return pq.top(); + + } +};