20/32
Part 4 of 6 · Deques and rate limitsLearn and do
One shared log holds only the requests that still count
The second row in that table is one deque that every key shares: a log of (time, key) pairs, oldest first. Next to it sits a dict from each key to how many of its requests still count. You'll finish this class in the editor.
Before each check, do three things for every pair at the front of the log that stopped counting:
- Drop it from the log.
- Take 1 off its key's count.
- Delete the key when its count reaches 0.
A shared log, 10-second window. At now = 13, which entries drop from the front?
Pick an answer above to see the rest