Skip to content

Commit e758da3

Browse files
authored
Update Solution.rs
1 parent 20e854f commit e758da3

File tree

1 file changed

+10
-8
lines changed
  • solution/1700-1799/1701.Average Waiting Time

1 file changed

+10
-8
lines changed
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
impl Solution {
22
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;
3+
let mut tot = 0.0;
4+
let mut t = 0;
5+
6+
for e in customers.iter() {
7+
let a = e[0];
8+
let b = e[1];
9+
t = t.max(a) + b;
10+
tot += (t - a) as f64;
1011
}
11-
spent_time as f64 / (customers.len() as f64)
12+
13+
tot / customers.len() as f64
1214
}
1315
}

0 commit comments

Comments
 (0)