class Solution {
public:
struct myCmp{
bool operator()(int & p1, int & p2){
return p1 > p2;
}
};
int findKthLargest(vector<int>& nums, int k) {
priority_queue<int, vector<int>, myCmp> pque;
for(auto& num : nums){
pque.push(num);
if(pque.size() > k){
pque.pop();
}
}
return pque.top();
}
};
11-17
07-15
447
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-14
935
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交