The Find Servers That Handled Most Number of Requests interview question is a load-balancing simulation. You have servers and a stream of requests. Each request arrives at time and takes time to process. A request is assigned to server (i % k) if it's free. If not, you check server (i+1) % k, and so on, until you find a free server or check all . You need to find which server(s) handled the maximum number of requests.
Companies like Amazon and Cisco ask this to test your ability to manage multiple dynamic states. It requires tracking both "when each server becomes free" and "which servers are currently available." It evaluates proficiency with Heap (Priority Queue) and Ordered Set data structures.
This problem follows the Two-Structure Priority Queue pattern.
(free_time, server_id) for servers currently working.TreeSet in Java) or two heaps to store IDs of servers that are currently idle.free_time <= t.free_time = t + duration., Requests: (t:1, d:5), (t:2, d:2), (t:3, d:3)
{(6, 0)}.{(6, 0), (4, 1)}.Master the use of Sorted Sets (TreeSet in Java, std::set in C++). They are essential for "next available" problems where you need to search for a value greater than or equal to a target in a dynamic collection.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Minimize Deviation in Array | Hard | Solve | |
| Make the Prefix Sum Non-negative | Medium | Solve | |
| Maximal Score After Applying K Operations | Medium | Solve | |
| Remove Stones to Minimize the Total | Medium | Solve | |
| Furthest Building You Can Reach | Medium | Solve |