FastPrepPer-Client Sliding-Window Rate Limiter
Problems/Per-Client Sliding-Window Rate Limiter

Per-Client Sliding-Window Rate Limiter

Nike, Inc. logoNike, Inc.● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Nike onsite interview for a full-time role. The original report asks for a sliding-window limiter for each client, with an allowRequest(clientId, timestamp) operation. It also asks for efficiency across clients and cleanup of inactive clients. It leaves out the exact boundary and what happens to rejected requests over time. We filled those in.

Our version is about 96% the same as the reported question.

Process an ordered batch of requests through a per-client sliding-window rate limiter. Each request i calls allowRequest(clientIds[i], timestamps[i]). A client may have at most limit accepted requests in the trailing windowSeconds seconds.

For a request at time timestamp, keep an earlier accepted request at time acceptedTime in the active window exactly when acceptedTime > timestamp - windowSeconds. Expire older accepted requests before deciding the current request. Accept the request when that client then has fewer than limit active accepted requests; an accepted request enters the window, while a rejected request does not.

Timestamps are globally nondecreasing, and requests at the same timestamp are processed in input order. Remove a client’s stored state as soon as it has no active accepted requests. Return one boolean decision for every request.

Function

allowRequests(clientIds: String[], timestamps: int[], limit: int, windowSeconds: int) → boolean[]

Examples

Example 1

clientIds = ["a","a","a","b","a","a"]timestamps = [0,1,2,2,3,5]limit = 3windowSeconds = 5return = [true,true,true,true,false,true]

Client a fills its window at times 0, 1, and 2, so its request at time 3 is rejected. At time 5, the accepted request at time 0 has expired, so the new request is accepted. Client b is independent.

Example 2

clientIds = ["x","x","x","x"]timestamps = [0,0,3,3]limit = 2windowSeconds = 3return = [true,true,true,true]

The first two same-time requests fill the window. At time 3, both accepted requests from time 0 are exactly at the expiration boundary and leave the window before either new request is processed.

Constraints

  • 1 <= clientIds.length <= 100000.
  • clientIds.length == timestamps.length.
  • Each client ID is a nonempty printable ASCII string of length at most 50.
  • 0 <= timestamps[i] <= 10^9.
  • timestamps is nondecreasing.
  • 1 <= limit <= 100000.
  • 1 <= windowSeconds <= 10^9.

More Nike, Inc. Onsite Interview questions

  • Flatten a Mixed JSON ListONSITE INTERVIEW · Seen Oct 2026
  • Hash Map with TTLONSITE INTERVIEW · Seen Oct 2026
  • Spiral MatrixONSITE INTERVIEW · Seen Oct 2026
  • Text Embedding and Vector SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026

Similar questions at other companies

  • Metric Counter with a Fake ClockSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
  • Per-Client Sliding-Window Rate LimiterGeneral Motors · OA
  • Completions API Rate LimiterCursor · PHONE SCREENCursor interview questions
  • Key-Value Store GET and PUT QPSDatabricks · PHONE SCREENDatabricks interview questions
  • Sliding-Window Rate LimiterAmazon · ONSITE INTERVIEW
  • Rate Limiter with Global and Per-User LimitsOpenAI · ONSITE INTERVIEWOpenAI interview questions
  • Per-Element Hit CounterUber · ONSITE INTERVIEWUber interview questions
  • Rate Limiter Sliding Window With Per-Entity LimitsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Article Vote TrackerRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Sliding-Window Rate LimiterStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
All Nike, Inc. interview questionsSee Nike, Inc. hiring insights
Saved
class Solution {
    public boolean[] allowRequests(String[] clientIds, int[] timestamps, int limit, int windowSeconds) {
        // Write your code here.
    }
}
Checking account…