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 0620cfb commit 20e854fCopy full SHA for 20e854f
solution/1700-1799/1701.Average Waiting Time/Solution.rs
@@ -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