During the day, a supermarket will receive calls from customers who want to place orders. The supermarket manager knows in advance the number of calls that will be attempted, the start time, duration, and order volume for each call. Only one call can be in progress at any one time, and if a call is not answered, the caller will not call back. The manager must choose which calls to service in order to maximize order volume. Determine the maximum order volume.
Complete the function phoneCalls in the editor.
phoneCalls has the following parameter(s):
int start[n]: the start times of each callint duration[n]: the durations of each callint volume[n]: the volumes of each order
Returns
int: the maximum possible volume of orders that can be received
Examples
01 · Example 1
start = [10, 5, 15, 18, 30] duration = [30, 12, 20, 35, 35] volume = [50, 51, 20, 25, 10] return = 76

Image above puts input data into a table 👆
The first call will start at time = 10, and last until time = 40.
The second call will start at time = 5, and last until time = 17.
The third call will start at time = 15, and last until time = 35.
The fourth call will start at time = 18, and last until time = 53.
The fifth call will start at time = 30, and last until time = 65.
The first call completely overlaps the second and third calls, and partially overlaps the fourth and fifth calls.
Choosing calls that do not overlap, and answering the 2nd and 4th calls leads to the maximum total order volume of 51 + 25 = 76.
Constraints
1 ≤ n ≤ 1051 ≤ start[i] ≤ 1091 ≤ duration[i] ≤ 1091 ≤ volume[i] ≤ 103
More Snowflake problems
- Drawing EdgeOA · Seen Jun 2026
- Horizontal Pod AutoscalerSeen Jun 2026
- Minimum HeightOA · Seen Jun 2026
- Effective Role PrivilegesPHONE SCREEN · Seen May 2026
- Closest Bathroom / Desk on a GridPHONE SCREEN · Seen May 2026
- Minimum Clicks Between Wiki PagesOA · Seen May 2026
- Minimum Index Distance Between Person and CakeOA · Seen May 2026
- Generating Login CodesOA · Seen May 2026
public int phoneCalls(int[] start, int[] duration, int[] volume) {
// write your code here
}
start[10, 5, 15, 18, 30]
duration[30, 12, 20, 35, 35]
volume[50, 51, 20, 25, 10]
expected76
sign in to submit