Skip to content

Practice Average Waiting Time

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

Medium#1701
LeetCode Problem

Average Waiting Time

Problem Statement

customers[i] = [arrival,time] lists customers in nondecreasing arrival order and their cooking durations. One chef prepares their orders in that order, starting each when both the chef and customer are available. Waiting time runs from the customer arrival until their order finishes, including cooking time. Return the mean waiting time; error within 10^-5 is accepted.

Source: Average Waiting Time on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
customers = [[1,2],[2,5],[4,3]]
Output
5.00000

# Example 2

Input
customers = [[5,2],[5,4],[10,3],[20,1]]
Output
3.25000

Constraints

1 <= customers.length <= 10^5
1 <= arrivali, timei <= 10^4
arrivali <= arrivali+1

Related LeetCode Problems

Practice more problems similar to Average Waiting Time.

Review your practice with PhantomCodeAI

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