Average Waiting Time LeetCode solution in Python

1
class Solution:
2
def averageWaitingTime(self, customers: List[List[int]]) -> float:
3
start = customers[0][0]
4
end = start + customers[0][1]
5
total_wait = end - start
6
for c in customers[1:]:
7
start = c[0]
8
if start <= end:
9
end += c[1]
10
total_wait = total_wait + end - start
11
else:
12
end = c[0] + c[1]
13
total_wait += c[1]
14
return total_wait / len(customers)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0