Drone API Sliding-Window Rate Limiter
Updated
Problem statement
Requests arrive in nondecreasing timestamp order. Request i comes from droneIds[i] at integer time timestamps[i].
Each drone may have at most maxRequests accepted requests in the inclusive interval [timestamps[i] - windowSeconds + 1, timestamps[i]]. A rejected request does not consume quota. Return one boolean per request indicating whether it is accepted.
Function
allowDroneRequests(droneIds: String[], timestamps: int[], windowSeconds: int, maxRequests: int) → boolean[]Examples
Example 1
droneIds = ["d1","d1","d1","d1"]timestamps = [1,2,3,4]windowSeconds = 3maxRequests = 2return = [true,true,false,true]The request at time 3 exceeds d1's quota; at time 4, the accepted request at time 1 has left the window.
Example 2
droneIds = ["d1","d2","d1"]timestamps = [5,5,5]windowSeconds = 10maxRequests = 1return = [true,true,false]Each drone has independent quota state.
Constraints
- The arrays have the same length from
0through100000. - Timestamps are nonnegative and nondecreasing.
1 <= windowSeconds, maxRequests <= 100000.- Drone IDs are non-empty ASCII strings.
More Skydio interview questions
Similar questions at other companies
- Stateful Paginated Fetch NLyft · PHONE SCREENLyft interview questions
- Sliding Window Rate LimiterMercury · PHONE SCREEN
- Dynamic Longest-Waiting Unique Task QueriesAmazon · PHONE SCREEN
- Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
- Transcript Window MetricsSesame · PHONE SCREEN
- Select First or Last K Stream WordsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Sliding Window Rate LimiterZipRecruiter · OA · ONSITE INTERVIEWZipRecruiter interview questions
- Capital Gains Tax from TradesArcesium · OAArcesium interview questions
- Incident MonitorStripe · OAStripe interview questions
- Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions