933. 最近的请求次数
作者:Annan
更新于:1 分钟前
字数统计:39 字
阅读时长:1 分钟
阅读量:
js
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
};