Find the Busiest Servers
Updated
Problem statement
There are k servers numbered 0 through k-1. Request i arrives at arrival[i] and takes load[i] time units.
Try server i modulo k first, then increasing server IDs with wraparound. Assign the request to the first free server in that cyclic order. Drop it if all servers are busy. A server completing at time t is free for a request arriving at t.
Return all server IDs that handle the largest number of requests, in increasing order.
Function
busiestServers(k: int, arrival: int[], load: int[]) → List<Integer>Examples
Example 1
k = 3arrival = [1,2,3,4,5]load = [5,2,3,3,3]return = [1]Requests 0, 1, and 2 use servers 0, 1, and 2. Server 1 finishes at time 4 and accepts request 3. Request 4 is dropped, so server 1 handles the most.
Example 2
k = 2arrival = [1,2,3]load = [1,1,1]return = [0]Each earlier request is finished before the next arrives. Requests 0 and 2 use server 0, while request 1 uses server 1.
Constraints
- 1 <= k <= 10000
- 1 <= arrival.length <= 20000
- load.length equals arrival.length.
- Arrival times strictly increase, and 1 <= arrival[i] <= 1000000000.
- 1 <= load[i] <= 1000000000
More Citadel Onsite Interview questions
- Maximize Workday EarningsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Minimum Changes for Palindromic BlocksOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Removal PoolONSITE INTERVIEW · Seen Sep 2026
- Centered K-by-K Submatrix SumsONSITE INTERVIEW · Seen Aug 2026
- Search Suggestions with a Prefix TreeONSITE INTERVIEW · Seen Aug 2026
- Traverse Interior Matrix Cells in Row-Major OrderONSITE INTERVIEW · Seen Aug 2026
- Time-Based Key-Value StorePHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2026
- 2048 Simulation and Board CodecONSITE INTERVIEW · Seen Jan 2026
- Cancellable Priority Task QueueONSITE INTERVIEW · Seen Jan 2026
- Dynamic Weighted SamplingONSITE INTERVIEW · Seen Jan 2026
Similar questions at other companies
- Finish Time of Fixed-Length CPU TasksGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Design Authentication ManagerOracle · ONSITE INTERVIEWOracle interview questions
- Delayed Job SchedulerWalmart Labs · ONSITE INTERVIEW
- Parallel Workers with a Per-Phase BarrierMakeMyTrip.com · ONSITE INTERVIEWMakeMyTrip.com interview questions
- Thread-Safe Task Storage and Worker DispatchNuro · ONSITE INTERVIEWNuro interview questions
- Notification Deduplication WindowGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
- Implement a Min-Priority QueueAmazon · ONSITE INTERVIEW
- Helpdesk Ticket ProcessingThe Walt Disney Company · ONSITE INTERVIEWThe Walt Disney Company interview questions
- API Call Thread Pool ScheduleBaseten · ONSITE INTERVIEWBaseten interview questions
- Execute Tasks by PrioritySnowflake · ONSITE INTERVIEWSnowflake interview questions