Problem · Array
Assign Tasks to Servers
Learn this problemProblem statement
You have an integer servers, which denote the number of servers, and you have a list called requests which denote the servers that this request is allowed to be scheduled to. You have to schedule each request to a server among servers 0 to requests[i] (inclusive) such that it is the least busy server. If multiple servers are the least, use the one with the least index. Return a list containing the server where each request was served.
Function
assignTasks(servers: int, requests: int[]) → int[]Examples
Example 1
servers = 5requests = [3, 1, 0, 2, 1]return = [0, 1, 0, 2, 1]N/A
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026