Trains the technique from
LeetCode 1701Average Waiting TimeThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
One press serves jobs in the order they arrive. customers[i] is a pair [arrival, minutes]: the minute the i-th job is handed in, and how long the press takes on it once started. Arrivals are given in non-decreasing order.
The press works on one job at a time, start to finish, and takes the next waiting job the moment it is free. If nothing is waiting, it idles until the next job arrives. A job's wait is the span from when it was handed in to when the press finishes it.
Return the average wait across all the jobs. An answer within 1e-5 of the true value is accepted.
Example 1
The first job runs from minute 3 to 10, waiting 7. The second was handed in at 4 but starts at 10 and ends at 12, waiting 8. The press then idles until minute 12 and finishes the third at 17, waiting 5. The three waits average to 20 divided by 3.
Example 2
One long job at the front holds up the three short ones behind it, which finish at minutes 12, 13 and 14.
Example 3
The press is long since free when the second job arrives, so neither job waits for anything but its own minute on the press.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def average_waiting_time(customers: list[list[int]]) -> float:public double averageWaitingTime(int[][] customers)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.