python
advanced
解決済み
2026-11-17 終了
Rate limiter (sliding window)
Implement a RateLimiter(limit, window) class whose allow(key, now) method returns True if the request is allowed.
- At most
limitrequests perkeyin anywindowseconds (a sliding window, not fixed buckets). nowis passed in (seconds as a float) so the tests are deterministic.- Different keys are independent.
- Memory for a key should not grow forever: drop timestamps that left the window.
これまでに 0 人が解きました。
エディターCtrl + Enter
テストが "All tests passed" と表示すると、このブラウザーでチャレンジが解決済みになります。
解答をレビューに提出