FastPrepSliding-Window Rate Limiter
Problems/Sliding-Window Rate Limiter

Sliding-Window Rate Limiter

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Bloomberg new grad phone screen. The author names a problem on a Chinese site, and links Design a Rate Limiting System after saying it is not Logger Rate Limiter. The linked firsthand reference gives the sliding-window rules and a follow-up where only allowed requests count. Here you get a finite batch of operations. Our version is about 99% the same as the reported question.

Given n, t, and a nondecreasing array timestamps, process the requests in order and return whether each one is allowed. The rate limiter allows at most n requests in any window of t integer seconds.

For a request at time x, the window is the inclusive range [x - t + 1, x]. Allow the request exactly when fewer than n previously allowed requests have timestamps in that window. A rejected request is not kept and does not affect later decisions.

Function

rateLimitRequests(n: int, t: int, timestamps: int[]) → boolean[]

Examples

Example 1

n = 3t = 5timestamps = [1,1,2,3,8]return = [true,true,true,false,true]

The first three requests fill the window, so the request at time 3 is rejected. By time 8, all earlier allowed requests have left the window.

Example 2

n = 1t = 3timestamps = [1,2,4,4]return = [true,false,true,false]

The rejected request at time 2 is not counted. The request at time 1 expires before time 4, so the first time-4 request is allowed.

Example 3

n = 2t = 2timestamps = [5,5,6,7]return = [true,true,false,true]

Both time-5 requests are active at time 6, so that request is rejected. They expire before time 7.

Constraints

  • 1 <= n <= 100000.
  • 1 <= t <= 1000000000.
  • 1 <= timestamps.length <= 100000.
  • 0 <= timestamps[i] <= 1000000000.
  • timestamps is nondecreasing.

More Bloomberg LP Phone Screen questions

  • Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Sliding-Window API Rate LimiterPatreon · PHONE SCREEN · ONSITE INTERVIEWPatreon interview questions
  • Rate Limiter Sliding Window With Per-Entity LimitsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Completions API Rate LimiterCursor · PHONE SCREENCursor interview questions
  • Key-Value Store GET and PUT QPSDatabricks · PHONE SCREENDatabricks interview questions
  • Sliding-Window Rate LimiterSnowflake · ONSITE INTERVIEWSnowflake interview questions
  • Per-Client Sliding-Window Rate LimiterGeneral Motors · OA
  • Metric Counter with a Fake ClockSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
  • Per-Client Sliding-Window Rate LimiterNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
  • API Shield with Two Rolling LimitsGraviton · OA
  • Per-User Sliding-Window Rate LimiterPayPal · OAPayPal interview questions

Interview reports that mention this question

  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
  • Bloomberg New Grad Interviews: 2025 vs 2026 Guide
  • Bloomberg New Grad Screens: 30 Experiences (Part 4 of 5)

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public boolean[] rateLimitRequests(int n, int t, int[] timestamps) {
        // Write your code here.
    }

}
Checking account…