python advanced Termina em 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 limit requests per key in any window seconds (a sliding window, not fixed buckets).
  • now is 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.

Resolvido por 0 pessoas até agora.

python
EditorCtrl + Enter

            
        

Quando os testes mostram "All tests passed", o desafio fica marcado como resolvido neste navegador.

Envie sua solução para revisão