We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 20e854f commit e758da3Copy full SHA for e758da3
solution/1700-1799/1701.Average Waiting Time/Solution.rs
@@ -1,13 +1,15 @@
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;
+ let mut tot = 0.0;
+ let mut t = 0;
+
+ for e in customers.iter() {
+ let a = e[0];
+ let b = e[1];
+ t = t.max(a) + b;
10
+ tot += (t - a) as f64;
11
}
- spent_time as f64 / (customers.len() as f64)
12
13
+ tot / customers.len() as f64
14
15
0 commit comments