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" दिखाते हैं, तो चैलेंज इस ब्राउज़र में हल के रूप में चिह्नित हो जाता है।
अपना समाधान समीक्षा के लिए भेजें