Sliding window log rate limiter
Your task
Simulate a sliding-window-log rate limiter. You are given requests, a list of integer arrival timestamps in non-decreasing order, a window length window, and a limit. A request at time t is ALLOWED iff, counting it, at most limit requests fall within the half-open window (t - window, t] (i.e. timestamps strictly greater than t-window and up to t, among requests that were themselves allowed). Rejected requests do not occupy the window. Return a list of booleans, one per request, indicating allowed (True) or rejected (False).
Examples
sliding_log_limiter(requests: list[int], window: int, limit: int) -> list[bool]Example 1
Input
sliding_log_limiter([1, 2, 3, 4], 3, 2)Output
[True, True, False, True]