Get Server IDs
Problem Overview
- Task: For each second i, assign the request to the server with the fewest requests among servers [0..requests[i]-1]; if tied, choose the smallest id; return the sequence of assigned server IDs.
- Inputs/Outputs: Given num_servers and an array requests; output an int array of server ids; all servers start with zero load.
- Constraints: 1 ≤ num_servers ≤ 1e5, 0 ≤ requests[i] < num_servers.
- Context: Load-balancing domain; from Amazon interviews, a coding interview problem and interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
