Description
A chef prepares orders one at a time. Given arrival times and preparation times, return the average waiting time.
Examples
Input:
customers = [[1,2],[2,5],[4,3]]Output:
5.0Explanation:
Customer 1 arrives at t=1, chef starts immediately, finishes at t=3 (wait=2). Customer 2 arrives at t=2, chef busy until t=3, finishes at t=9 (wait=7). Customer 3 arrives at t=4, chef busy until t=9, finishes at t=12 (wait=8). Average wait = (2+7+8)/3 = 5.67.
Input:
customers = [[3,1],[6,2],[8,1]]Output:
1.33Explanation:
Customer 1 arrives at t=3, finishes at t=4 (wait=1). Customer 2 arrives at t=6, finishes at t=8 (wait=2). Customer 3 arrives at t=7, chef busy until t=8, finishes at t=9 (wait=2). Average = (1+2+2)/3 = 1.67.
Input:
customers = [[0,3]]Output:
0.0Explanation:
A single customer arrives at time 0, preparation takes 3 minutes, finishes at t=3. Waiting time is 3-0=3. Average is 3.0.
Constraints
- •
1 ≤ customers.length ≤ 10⁵