Algobase
Problems
Get Premium
Pricing
Problems
/
280. Number of Recent Calls
Prev
Next
Visualizer
Problem
Solution
Code
Mixed Interleaved Pings
Rapid Pings
Sparse Pings (Evictions)
⌥
Visualizer will appear here
Problem
Solution
Code
1
class RecentCounter:
2
def __init__(self):
3
self.q = []
4
def ping(self, t):
5
self.q.append(t)
6
while self.q[0] < t - 3000:
7
self.q.pop(0)
8
return len(self.q)
Visualizer
Mixed Interleaved Pings
Rapid Pings
Sparse Pings (Evictions)
⌥
Visualizer will appear here