933. 最近的请求次数

36 字
1 分钟
933. 最近的请求次数
var RecentCounter = function() {
this.queue = []
};
/**
* @param {number} t
* @return {number}
*/
RecentCounter.prototype.ping = function(t) {
this.queue.push(t)
const queueHead = this.queue[0]
while(queueHead < t-3000) {
this.queue.shift();
}
return this.queue.length
};

文章分享

如果这篇文章对你有帮助,欢迎分享给更多人!

933. 最近的请求次数
https://an2333.com/posts/basic/algorithm/queue/933/
作者
Annan
发布于
2025-05-05
许可协议
CC BY-NC-SA 4.0
Profile Image of the Author
Annan
写点前端,聊点 AI。
公告
博客已迁移到 Astro + Firefly,旧文章正在陆续搬家中。
分类
标签
站点统计
文章
50
分类
7
标签
28
总字数
84,160
运行时长
0 天
最后活动
0 天前
站点信息
构建平台
GitHub Actions
博客版本
Firefly v6.16.8
文章许可
CC BY-NC-SA 4.0

当前页面没有目录

文章目录

当前页面没有目录