Skip to content

Practice Find Servers That Handled Most Number of Requests

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#1606
LeetCode Problem

Find Servers That Handled Most Number of Requests

Problem Statement

There are k servers numbered 0 through k - 1, each able to process one request at a time. Request i arrives at arrival[i] and occupies its server for load[i] time units. Assign it to the first free server found by scanning cyclically from i % k; drop it if every server is busy. Return all server ids with the greatest number of handled requests, in any order.

Source: Find Servers That Handled Most Number of Requests on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3]
Output
[1]

# Example 2

Input
k = 3, arrival = [1,2,3,4], load = [1,2,1,2]
Output
[0]

# Example 3

Input
k = 3, arrival = [1,2,3], load = [10,12,11]
Output
[0,1,2]

Constraints

1 <= k <= 10^5
1 <= arrival.length, load.length <= 10^5
arrival.length == load.length
1 <= arrival[i], load[i] <= 10^9
arrival is strictly increasing.

Related LeetCode Problems

Practice more problems similar to Find Servers That Handled Most Number of Requests.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.