Sliding window log limiter

Write codeMedium25 minStripe and Amazon style

Your task

Implement a sliding-window-log rate limiter allowing at most max_req requests within any window-length time window. Given a chronologically ordered list of request timestamps, a request at time ts is allowed if, after dropping all logged timestamps <= ts - window, fewer than max_req remain; if allowed, its timestamp is logged. Return a list of booleans. Timestamps are non-decreasing.

Examples

sliding_window_log(window: int, max_req: int, requests: list[int]) -> list[bool]
Example 1
Inputsliding_window_log(10, 2, [1, 2, 3])
Output[True, True, False]