Skip to content

Commit 1c6ae67

Browse files
authored
Solution rust
1 parent b8cc919 commit 1c6ae67

File tree

1 file changed

+13
-0
lines changed
  • solution/1700-1799/1701.Average Waiting Time

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
impl Solution {
2+
pub fn average_waiting_time(customers: Vec<Vec<i32>>) -> f64 {
3+
let mut spent_time = 0;
4+
let mut time_waited = 0;
5+
for customer in &customers {
6+
let a = customer[0] as i64;
7+
let b = customer[1] as i64;
8+
time_waited = time_waited.max(a) + b;
9+
spent_time += time_waited - a;
10+
}
11+
spent_time as f64 / (customers.len() as f64)
12+
}
13+
}

0 commit comments

Comments
 (0)