VIP-Priority Fixed-Window Rate Limiter
Updated
Problem statement
You are given a positive periodLength and a timestamp-ordered array of requests. Each request is [timestamp, userId, isVip], where isVip is 1 for a VIP request and 0 otherwise.
Timestamps are divided into fixed half-open periods [q * periodLength, (q + 1) * periodLength). At most five request occurrences may be admitted in each represented period. Every occurrence consumes one capacity slot, even when multiple requests use the same userId. Resolve every period as a finite batch: admit VIP requests first, then normal requests, while preserving arrival order within each class. Return one boolean per request in original input order indicating whether it is admitted.
Function
admitVipPriorityRequests(requests: int[][], periodLength: int) → boolean[]Examples
Example 1
requests = [[0,101,0],[1,102,0],[2,103,1],[3,104,0],[4,105,1],[5,106,0],[6,107,1]]periodLength = 10return = [true,true,true,false,true,false,true]The three VIP requests are admitted first. The first two normal requests fill the remaining capacity, so the later normal requests are rejected.
Example 2
requests = [[0,1,0],[9,2,0],[10,3,0],[19,4,1],[20,5,0],[20,6,1]]periodLength = 10return = [true,true,true,true,true,true]The requests occupy three periods, and each period has its own five-request capacity.
Example 3
requests = [[3,1,0],[3,2,0],[3,3,0],[3,4,0],[3,5,0],[3,6,1]]periodLength = 5return = [true,true,true,true,false,true]The VIP request takes one slot even though it arrives last. The first four normal requests keep their stable order.
Constraints
1 <= periodLength <= 10^9.0 <= requests.length <= 2 * 10^5.- Every request contains exactly three integers: a timestamp, a user identifier, and a VIP flag.
- Timestamps are in
[0, 10^9]and are nondecreasing. - User identifiers are signed 32-bit integers, and every VIP flag is
0or1. - Each request occurrence consumes one capacity slot, including repeated user identifiers.
More Intuit interview questions
- VIP and Regular Service SchedulerPHONE SCREEN · Seen Nov 2026
- Longest Uninterrupted Work BlockPHONE SCREEN · Seen Sep 2026
- Small Business Network: Degrees of SeparationPHONE SCREEN · Seen May 2026
- Longest Common SubstringPHONE SCREEN · Seen May 2021
- Lowest Common Ancestor in a Rooted TreePHONE SCREEN · Seen Feb 2020
- Zero or One Parent Groups in a TreePHONE SCREEN · Seen Feb 2020
- Number of IslandsONSITE INTERVIEW · Seen Nov 2026
- Employee Promotion OpportunitiesOA · Seen Oct 2026
- Next Pascal Row CoefficientOA · Seen Oct 2026
- Parse Router LogsOA · Seen Oct 2026
Similar questions at other companies
- Bus Station Seat AllotmentInMobi · PHONE SCREENInMobi interview questions
- Recipe Rating ServiceNubank · PHONE SCREEN
- In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
- Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesStripe · PHONE SCREENStripe interview questions
- Determine the Winner of Three-Card HandsOpenAI · PHONE SCREENOpenAI interview questions
- Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
- Alert Engine with a Repeat IntervalChronosphere · PHONE SCREEN
- Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
- Finish Time of Fixed-Length CPU TasksGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Camel CardsRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions