class RecentCounter {
int count;
public RecentCounter() {
this.count=0;
}
Queue<Integer> queue=new LinkedList<>();
public int ping(int t) {
int c=0;
queue.offer(t);
Queue<Integer> myqueue=new LinkedList<>(queue);
while(!myqueue.isEmpty()){
int x=myqueue.poll();
if(x>=t-3000&&x<=t) {
c++;
}else{
queue.poll();
}
}
return c;
}
}
/**
* Your RecentCounter object will be instantiated and called as such:
* RecentCounter obj = new RecentCounter();
* int param_1 = obj.ping(t);
*/