Skip to content

Commit 8079aa6

Browse files
authored
Rust Solution added
1 parent b8cc919 commit 8079aa6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

solution/1700-1799/1701.Average Waiting Time/README_EN.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,24 @@ function averageWaitingTime(customers: number[][]): number {
159159
}
160160
```
161161

162+
#### Rust
163+
164+
```rust
165+
impl Solution {
166+
pub fn average_waiting_time(customers: Vec<Vec<i32>>) -> f64 {
167+
let mut spent_time = 0;
168+
let mut time_waited = 0;
169+
for customer in &customers {
170+
let a = customer[0] as i64;
171+
let b = customer[1] as i64;
172+
time_waited = time_waited.max(a) + b;
173+
spent_time += time_waited - a;
174+
}
175+
spent_time as f64 / (customers.len() as f64)
176+
}
177+
}
178+
```
179+
162180
<!-- tabs:end -->
163181

164182
<!-- solution:end -->

0 commit comments

Comments
 (0)