标签:ant code anti ram lin led recent size ret
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
标签:ant code anti ram lin led recent size ret
原文地址:https://www.cnblogs.com/exhausttolive/p/10612535.html