博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
leetcode703
阅读量:7086 次
发布时间:2019-06-28

本文共 592 字,大约阅读时间需要 1 分钟。

class KthLargest {public:    KthLargest(int k, vector
nums) { size = k; for(auto num:nums){ pq.push(num); if(pq.size() > size) pq.pop(); } } int add(int val) { pq.push(val); if(pq.size() > size) pq.pop(); return pq.top(); }private: priority_queue
, greater
> pq; int size;};/** * Your KthLargest object will be instantiated and called as such: * KthLargest obj = new KthLargest(k, nums); * int param_1 = obj.add(val); */

 

转载于:https://www.cnblogs.com/asenyang/p/9734865.html

你可能感兴趣的文章
DEDECMS 常见错误
查看>>
Cacti 备份与迁移
查看>>
zabbix 监控ElasticSearch
查看>>
Oracle日志查看
查看>>
Simplify Your Life With an SSH Config File
查看>>
fork, clone, add, commit, fetch, rebase, push流程测试
查看>>
exchange删除邮件
查看>>
Mysql索引总结
查看>>
5、分区格式化、压缩、挂载、解压 学习笔记
查看>>
Android Studio databinding找不到BR的问题
查看>>
排序算法------快速排序
查看>>
我的友情链接
查看>>
修改APACHE端口后启动出错,原来是SELINUX安全问题。
查看>>
我的友情链接
查看>>
Windows azure中公用云服务的两个虚机FTP的设置
查看>>
htmlunit 设置cookis
查看>>
jms异步通信全攻略
查看>>
Apache2 服务器异常问题Your browser sent a request that this server could not understan
查看>>
HTTP常见状态码
查看>>
提交版本审核提示无效二进制文件Apps are not allowed to listen to device lock notifications....
查看>>