class RecentCounter {
private Queue<Integer> queue;
private int windowSize;
public RecentCounter() {
queue = new LinkedList<>();
windowSize = 3000;
}
public int ping(int t) {
queue.offer(t);
while(queue.peek() + 3000 < t){
queue.poll();
}
return queue.size();
}
}
/**
* Your RecentCounter object will be instantiated and called as such:
* RecentCounter obj = new RecentCounter();
* int param_1 = obj.ping(t);
*/
最近请求次数java实现
最新推荐文章于 2023-03-28 15:51:30 发布