Your question is Sliding Window Rate Limiter. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
At Stripe, you need an in-memory rate limiter that decides whether each request should be allowed.
Implement rate_limit(timestamps, limit, window_seconds) that returns a boolean decision for every request timestamp.
timestamps: list[int] (non-decreasing)limit: int maximum number of allowed requests in any windowwindow_seconds: int window size in secondst, consider the inclusive window [t - window_seconds, t].list[bool] where True means allow, False means deny.def rate_limit(timestamps: list[int], limit: int, window_seconds: int) -> list[bool]: