def rate_limiter(requestTimestamps: list[int], windowLength: int, maxRequests: int,
inclusiveStart: bool = False) -> list[bool]:A sliding-window rate limiter in two parts. It is the Roblox coding question our sources report most often, usually in the phone screen and sometimes in an onsite coding round. The platform shows the description and given signatures next to the editor and runs visible test cases plus hidden ones; you write the functions, not a main program.
Requests arrive as a list of timestamps sorted in increasing order (equal timestamps are allowed on this page). For each request, decide whether it is allowed (True) or denied (False), and return the list of decisions in request order. Only allowed requests are recorded; a denied request never counts against a later one.
Part 1 — Global sliding window
rate_limiter(requestTimestamps, windowLength, maxRequests, inclusiveStart=False) -> list[bool]: a request at time t is allowed when fewer than maxRequests allowed requests fall in the window (t - windowLength, t]. A request exactly windowLength earlier no longer counts.
Example: rate_limiter([1, 2, 3, 4, 5, 6], 3, 2) returns [True, True, False, True, True, False]. t=3 is denied (t=1 and t=2 are in the window); t=4 is allowed because t=1 has left the window and the denied t=3 was never recorded.
The prompt's notation writes the window as [t - windowLength, t], but its worked example leaves the left end out, and the two readings give different answers on that example. Ask which one is meant. The default here follows the example; inclusiveStart=True switches to [t - windowLength, t], where the same input gives [True, True, False, False, True, True]. The flag is our addition so the tests can show the difference.
Follow-ups reported (not graded)
One report's follow-up was a request with several fields, each limited separately; another's was per-IP limiting. Both are the Part 2 structure with one map of queues per field.
Keep a map from user id to a queue of allowed timestamps and a separate map from experience id to its queue (one candidate: two maps holding the queues; another: dict plus deque). Expire both queues, deny if either is full, and append to both only when the request is allowed; the given example's t=5 result requires that a denied request is not recorded.
Standard explanation — no candidate report records what the interviewer accepted here.
Our answer: the same structure for any number of fields, one map keyed by (field, value) or one map per field; a request is denied when any field's queue is full and recorded on every field only when allowed.
Standard explanation — no candidate report records what the interviewer accepted here.
Our answer: O(n) time, since each timestamp is pushed and popped at most once per queue. Space: O(maxRequests) for Part 1. Part 2 holds at most maxRequests timestamps per user and per experience, plus a map entry for every user and experience ever seen (O(U + E) keys, since nothing deletes them), so O(n) in the worst case.
Standard explanation — no candidate report records what the interviewer accepted here.
Our answer: the same sliding window keyed by IP, a map from IP to its queue of allowed timestamps.
Standard explanation — no candidate report records what the interviewer accepted here.
Our answer: deleting a key only when it is next touched reclaims returning keys but never a key that does not come back, so it does not stop the growth on its own. Sweep periodically and drop every key whose newest allowed timestamp has left the window, or keep the keys in an expiry heap (or timing wheel) ordered by their last allowed time. Not confirmed for this question: one report mentions garbage collection in an onsite 'IP bot check' round it does not describe.
The Roblox coding question reported most often in our sources, from mid-2025 to mid-2026: mostly phone screens, a few times an onsite or VO coding round, and once a senior MLE coding round. Several reports describe a 45-minute round.
The prompt arrives on a CodeSignal-style platform with the signatures, a docstring and a worked example for each part, and runs visible plus hidden test cases; one candidate notes that a failed hidden case is not shown. Two reports give the prompt in full, with the same examples used on this page; a third gives the same examples under the name global_rate_limiter.
Outcomes are mixed. Two candidates could not get a hidden test to pass on Part 2: one had passed the given tests and failed the round, the other suspected the platform's own reference was wrong. Another candidate missed two hidden cases and still passed, and said it depends on the interviewer. One candidate passed every test and was told by the interviewer that a typo bug had slipped past the tests. One candidate failed on time after spending too long on Part 1. After Part 2, one interviewer asked about complexity.
Follow-ups vary: one report had a request with several fields to limit separately, one had per-IP limits, and in one Part 1 was already per user with a per-game limit added in Part 2. The question is also described as validating a stream of log events where each user may emit only a fixed number of events per time window.
Also reported as Sliding Window Rate Limiter · Per-Entity Rate Limiter
A sliding-window rate limiter in two parts. It is the Roblox coding question our sources report most often, usually in the phone screen and sometimes in an onsite coding round. The platform shows the description and given signatures next to the editor and runs visible test cases plus hidden ones; you write the functions, not a main program.
Requests arrive as a list of timestamps sorted in increasing order (equal timestamps are allowed on this page). For each request, decide whether it is allowed (True) or denied (False), and return the list of decisions in request order. Only allowed requests are recorded; a denied request never counts against a later one.
Part 1 — Global sliding window
rate_limiter(requestTimestamps, windowLength, maxRequests, inclusiveStart=False) -> list[bool]: a request at time t is allowed when fewer than maxRequests allowed requests fall in the window (t - windowLength, t]. A request exactly windowLength earlier no longer counts.
Example: rate_limiter([1, 2, 3, 4, 5, 6], 3, 2) returns [True, True, False, True, True, False]. t=3 is denied (t=1 and t=2 are in the window); t=4 is allowed because t=1 has left the window and the denied t=3 was never recorded.
The prompt's notation writes the window as [t - windowLength, t], but its worked example leaves the left end out, and the two readings give different answers on that example. Ask which one is meant. The default here follows the example; inclusiveStart=True switches to [t - windowLength, t], where the same input gives [True, True, False, False, True, True]. The flag is our addition so the tests can show the difference.
Part 2 — Per user and per experience
per_entity_rate_limiter(requestTimestamps, userIds, experienceIds, windowLength, maxRequests) -> list[bool]: request i comes from user userIds[i] in experience experienceIds[i]. Every user and every experience has its own window, (t - windowLength, t], with the same maxRequests. A request is denied when either its user or its experience already has maxRequests allowed requests in the window; when allowed, it is recorded for both.
Example: per_entity_rate_limiter([1, 2, 3, 4, 5], [1, 1, 2, 1, 2], ["A", "A", "A", "A", "B"], 3, 1) returns [True, False, False, True, True]. t=2 is denied on the user (user 1 used its one request at t=1); t=3 is denied on the experience (A used its one request at t=1); t=5 is allowed, because the denied t=3 never used user 2's budget.
Follow-ups reported (not graded)
One report's follow-up was a request with several fields, each limited separately; another's was per-IP limiting. Both are the Part 2 structure with one map of queues per field.
Rate limit per IP address. (when: After Part 1 (one report))
Now limit independently per user id AND per experience id. A request is denied if either limit is exceeded.
What if a request has several fields, each of which needs its own limit? (when: After Part 1 (one report, as its second part))
What is the time and space complexity? (when: After Part 2 (one report))
How would you clean up keys that have gone idle, so the maps do not grow forever?
| Approach | Notes |
|---|---|
| Sets or sorted containers per key | One report says the follow-up solution added some sets. A sorted structure also handles unsorted timestamps, at O(log n) per operation; with sorted input a queue is simpler (our assessment). |
| Token bucket or fixed-window counter | Our note: less memory, but they give different answers from the sliding-window examples in the prompt, so they do not pass this round's tests. |
Common mistakes: One candidate had not worked out the condition for removing expired timestamps from the queue, got the wrong result and needed many hints.; Two candidates could not pass a hidden test on Part 2; one had passed the given tests and failed the round, the other suspected the platform's reference solution.; One candidate who failed said nerves made them spend too long on Part 1, leaving no time to fix a small bug later.; Our recommendation: in Part 2, check both queues before appending to either; appending to one first lets a request denied on the other axis use up budget.; Our recommendation: write only the given functions; on this platform a main program is not needed (one candidate lost time to that in a different Roblox round).
Interviewer hints: One candidate who had not thought through the expiry condition received many hints from the interviewer.; One interviewer pointed out a typo bug that the test cases had not caught.; One interviewer asked about complexity after Part 2.; The platform runs visible and hidden test cases; one candidate notes a failed hidden case is not shown.
What passers do: One candidate who moved forward used a deque for Part 1 and a dict of deques for the follow-up.; One candidate missed two hidden test cases and still passed the round; their view was that it depends on the interviewer.; One candidate who passed every test case was told afterwards by the interviewer that a typo bug had gone uncaught by the tests.
If you have had this round, tell us how close this page was. It is how we keep the pages accurate.
Send them this page. It is free to read, no account needed.
What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 37 Roblox questions, refreshed monthly from new candidate reports.