题目:原题链接(中等)
标签:数学、数组
解法 | 时间复杂度 | 空间复杂度 | 执行用时 |
Ans 1 (Python) | O ( N ) | O ( 1 ) | 140ms (63.43%) |
Ans 2 (Python) | |||
Ans 3 (Python) |
解法一:
class Solution:
def averageWaitingTime(self, customers: List[List[int]]) -> float:
size = len(customers)
ans = 0
now = 0
for arrival, time in customers:
if now < arrival:
ans += time
now = arrival + time
else:
ans += (now - arrival) + time
now += time
return ans / size