Average Waiting Time LeetCode solution in Java

1
class Solution {
2
public double averageWaitingTime(int[][] customers) {
3
double time = 0;
4
double waitingTime = 0;
5

6
for (int[] cust : customers) {
7
time = Math.max(cust[0], time);
8
time = time + cust[1];
9
waitingTime += (time - cust[0]);
10
}
11

12
return waitingTime / customers.length;
13
}
14
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0