15 lines
495 B
Python
15 lines
495 B
Python
# https://leetcode.com/problems/average-waiting-time/
|
|
from typing import List
|
|
|
|
class Solution:
|
|
def averageWaitingTime(self, customers: List[List[int]]) -> float:
|
|
available = customers[0][0]
|
|
waiting = 0;
|
|
for time in customers:
|
|
if time[0] < available:
|
|
waiting += available - time[0]
|
|
else:
|
|
available = time[0]
|
|
waiting += time[1]
|
|
available += time[1]
|
|
return waiting / len(customers)
|