Skip to content

Commit af6b0bb

Browse files
committed
1701. Average Waiting Time
1 parent 8c2e4fd commit af6b0bb

File tree

1 file changed

+14
-0
lines changed
  • solutions/1701. Average Waiting Time

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def average_waiting_time(customers: list[list[int]]) -> float:
2+
total_time = 0
3+
waiting_times = []
4+
for customer in customers:
5+
if customer[0] < total_time:
6+
total_time += customer[1]
7+
waiting_times.append(total_time - customer[0])
8+
else:
9+
total_time = customer[1] + customer[0]
10+
waiting_times.append(customer[1])
11+
return round(sum(waiting_times) / len(customers), 5)
12+
13+
14+
print(average_waiting_time([[1, 2], [2, 5], [4, 3]]))

0 commit comments

Comments
 (0)