File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed
solution/1700-1799/1701.Average Waiting Time Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,26 @@ function averageWaitingTime(customers: number[][]): number {
161
161
}
162
162
```
163
163
164
+ #### Rust
165
+
166
+ ``` rust
167
+ impl Solution {
168
+ pub fn average_waiting_time (customers : Vec <Vec <i32 >>) -> f64 {
169
+ let mut tot = 0.0 ;
170
+ let mut t = 0 ;
171
+
172
+ for e in customers . iter () {
173
+ let a = e [0 ];
174
+ let b = e [1 ];
175
+ t = t . max (a ) + b ;
176
+ tot += (t - a ) as f64 ;
177
+ }
178
+
179
+ tot / customers . len () as f64
180
+ }
181
+ }
182
+ ```
183
+
164
184
#### JavaScript
165
185
166
186
``` js
Original file line number Diff line number Diff line change @@ -159,6 +159,26 @@ function averageWaitingTime(customers: number[][]): number {
159
159
}
160
160
```
161
161
162
+ #### Rust
163
+
164
+ ``` rust
165
+ impl Solution {
166
+ pub fn average_waiting_time (customers : Vec <Vec <i32 >>) -> f64 {
167
+ let mut tot = 0.0 ;
168
+ let mut t = 0 ;
169
+
170
+ for e in customers . iter () {
171
+ let a = e [0 ];
172
+ let b = e [1 ];
173
+ t = t . max (a ) + b ;
174
+ tot += (t - a ) as f64 ;
175
+ }
176
+
177
+ tot / customers . len () as f64
178
+ }
179
+ }
180
+ ```
181
+
162
182
#### JavaScript
163
183
164
184
``` js
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ pub fn average_waiting_time ( customers : Vec < Vec < i32 > > ) -> f64 {
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 ;
11
+ }
12
+
13
+ tot / customers. len ( ) as f64
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments