leetcode 933. Number of Recent Calls
Posted exhausttolive
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode 933. Number of Recent Calls相关的知识,希望对你有一定的参考价值。
class RecentCounter {
Queue<Integer> q;
public RecentCounter() {
q = new LinkedList<Integer>();
}
public int ping(int t) {
int threshold = t - 3000;
while (q.size() != 0 && q.peek() < threshold) {
q.poll();
}
q.add(t);
return q.size();
}
}
/**
* Your RecentCounter object will be instantiated and called as such:
* RecentCounter obj = new RecentCounter();
* int param_1 = obj.ping(t);
*/
以上是关于leetcode 933. Number of Recent Calls的主要内容,如果未能解决你的问题,请参考以下文章
[LeetCode] 933. Number of Recent Calls 最近的调用次数
LeetCode.933-最近通话次数(Number of Recent Calls)
Leetcode-933 Number of Recent Calls(最近的请求次数)