In-Memory Sliding-Window Rate Limiter
Asked at Patreon · Coding & Leetcode-style Questions · Difficulty: Medium · Last asked Oct 5, 2026
Implement an in-memory rate limiter that protects one API endpoint. It is created with `max_per_second`, the most requests it may accept in any one-second window. Each time a request arrives, the endpoint calls `allow(timestamp_ms)`, and the limiter accepts (`True`) or rejects (`False`) it.
Loading the problem…