Company: Byte Dance
Difficulty: medium
Maximize Throughput A cloud provider operates a large fleet of data centers where thousands of interconnected servers process concurrent requests, handle user interactions, and deliver data to users worldwide. Each server belongs to a dynamic task-execution flow, represented by an array serverTasks , where each entry gives the next server in the chain that would handle a forwarded task. Keeping the pipeline efficient means carefully managing how tasks are handed off between servers. When server i is chosen, it hands its task to server serverTasks[i] , shifting the load there. That hand-off, however, immediately locks both server i and server serverTasks[i] out of taking part in any further hand-offs, since they are now occupied processing the transferred load. Because of this, the order and choice of servers used for hand-offs directly determines how much total throughput can be achieved. Each server at index i forwards to server serverTasks[i] . As soon as that forwarding happens, bot