Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int findKthLargest(vector<int>& nums, int k) {
- priority_queue<int, vector<int>, greater<int>> heap;
- for(int num:nums){
- heap.push(num);
- if(heap.size() > k)
- heap.pop();
- }
- return heap.top();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement