InferenceAI

Enter at least two characters to search.

Start free

Fixed Window Rate Limit

mediumProduction AI20 min25 XP

Given sorted request seconds, window size and limit, return booleans indicating whether each request is allowed. Count only allowed requests in the current fixed window.

Examples

EXAMPLE WALKTHROUGHwindow reset

A guided view of the published example, not a trace of your code.

INPUT[[0,1,2,11],10,2]
TASKallow_requests()
EXPECTED OUTPUT[true,true,false,true]

Start with the input values shown in this example.

Example 1 of 2

Input: times = [0,1,2,11], window = 10, limit = 2

Output: [true,true,false,true]

Explanation: window reset

Input: times = [], window = 10, limit = 1

Output: []

Explanation: empty

Hint 1

Use floor(time/window) as the fixed-window ID.

Topics

PythonProduction AI