# 练习

# LeetCode.933.最近的请求次数


var RecentCounter = function () {
    this.q = [];
};

/** 
 * @param {number} t
 * @return {number}
 */
RecentCounter.prototype.ping = function (t) {
    this.q.push(t);
    while (this.q[0] < t - 3000) {
        this.q.shift()
    }
    return this.q.length
};

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17