Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class HitCounter:
- def __init__(self):
- self.counter = deque()
- def hit(self, timestamp: int) -> None:
- self.counter.append(timestamp)
- def getHits(self, timestamp: int) -> int:
- while len(self.counter) > 0 and self.counter[0] <= timestamp - 300:
- self.counter.popleft()
- return len(self.counter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement