当前位置:网站首页>Daily question 1: recent requests (Sword finger offer042)
Daily question 1: recent requests (Sword finger offer042)
2022-07-19 00:16:00 【Baking soda】

Ideas : Use a queue , Insert request , When the request time is 3000 Out of milliseconds , Request to exit the queue
class RecentCounter {
Queue<Integer> queue;
public RecentCounter() {
queue = new ArrayDeque<Integer>();
}
public int ping(int t) {
queue.offer(t);
while (queue.peek() < t - 3000) {
queue.poll();
}
return queue.size();
}
}边栏推荐
- Redis分布式缓存-数据持久化
- Study with passion
- [Baidu PaddlePaddle] handwritten numeral recognition model deployment pad influence
- OpenCV DFT
- boost.property_tree解析xml的帮助类以及中文解析问题的解决
- QT工具——moc、rcc、uic
- Checked to display and hide the hearts of favorite buttons
- [where can I buy Huawei hcie examination papers?]
- Collection of various materials about websocket
- 2022 - 07 - 16 notes d'étude pour le cours d'auto - culture du groupe 5 (tous les jours)
猜你喜欢

Delphi 485 Modbus Rtu读写RFID示例源码

WordPress Theme sharing: Avada theme v7.8.0 download the latest version in 2022 for free

MySQL one basic syntax

OpenPose:使用部分亲和场的实时多人 2D 姿势估计

P5js coffee cup steaming JS special effect

Delphi 485 Modbus RTU reading and writing RFID example source code

Redis三种模式——主从复制、哨兵模式、集群

WordPress主题分享:Flatsome主题v3.15.7免费下载 2022年最新版

OpenCV DFT

Mise en œuvre du modèle word2vec skip Gram
随机推荐
Delphi 485 Modbus RTU reading and writing RFID example source code
外部PLC触发VisionMaster多流程运行PLC部分特殊说明
CodeTON Round 1 (Div. 1 + Div. 2, Rated, Prizes)(A-C)
go+mysql+redis+vue3简单聊室,第5弹:使用消息队列和定时任务同步消息到mysql
Word2Vec Skip-gram 模型實現
TCP 糊涂窗口综合症(silly window syndrome)与 rate-based 流控
Visionmaster communicates MODBUS with youao robot ur5e
从零开始配置 vim(4)——键盘映射的一些技巧
云平台简易上手操作
boost. property_ The help class of tree parsing XML and the solution of Chinese parsing problem
[examination] answer to the examination of class 2201 in stage II (no responsibility for mistakes)
关于Go Modules环境搭建和包管理工具的使用
OpenPose:使用部分親和場的實時多人 2D 姿勢估計
VMware6.0连接群晖iscsi
2022 - 07 - 16 notes d'étude pour le cours d'auto - culture du groupe 5 (tous les jours)
The relationship between filedescriptor and open file in liunx
Stateless design of application
About the use of go modules environment construction and package management tools
笔记
Solution to the problem of heavy snow Vegetable Flavor -- p4017 maximum food chain count