class RecentCounter:
def __init__(self):
self.queue = []
def ping(self, t: int) -> int:
queue = self.queue
queue.append(t)
while queue and queue[0] < t - 3000:
queue.pop(0)
return len(queue)
# Your RecentCounter object will be instantiated and called as such:
# obj = RecentCounter()
# param_1 = obj.ping(t)
用 queue 來做,判斷 queue 中的 element 何時消失