Hard · System Design
Find Servers That Handled Most Number of Requests
Given k servers numbered 0 to k-1 and requests with strictly increasing arrival times, where request i keeps its server busy from arrival[i] until arrival[i] + load[i] (the server is free again at that moment), send request i to the first free server at or after i mod k (wrapping around), or drop it if every server is busy; return the ids of all servers that handled the most requests, in any order.
Examples
Example 1
k=3, arrival=[1,2,3,4,5], load=[5,1,4,3,2]Output: [1]
Example 2
k=3, arrival=[1,2,3,4,5,6], load=[4,4,3,1,2,1]Output: [0,2]
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.