File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
solution/1700-1799/1701.Average Waiting Time Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,19 @@ function averageWaitingTime(customers: number[][]): number {
161
161
}
162
162
```
163
163
164
+ #### JavaScript
165
+
166
+ ``` js
167
+ function averageWaitingTime (customers ) {
168
+ let [tot, t] = [0 , 0 ];
169
+ for (const [a , b ] of customers) {
170
+ t = Math .max (t, a) + b;
171
+ tot += t - a;
172
+ }
173
+ return tot / customers .length ;
174
+ }
175
+ ```
176
+
164
177
<!-- tabs: end -->
165
178
166
179
<!-- solution: end -->
Original file line number Diff line number Diff line change @@ -159,6 +159,19 @@ function averageWaitingTime(customers: number[][]): number {
159
159
}
160
160
```
161
161
162
+ #### JavaScript
163
+
164
+ ``` js
165
+ function averageWaitingTime (customers ) {
166
+ let [tot, t] = [0 , 0 ];
167
+ for (const [a , b ] of customers) {
168
+ t = Math .max (t, a) + b;
169
+ tot += t - a;
170
+ }
171
+ return tot / customers .length ;
172
+ }
173
+ ```
174
+
162
175
<!-- tabs: end -->
163
176
164
177
<!-- solution: end -->
Original file line number Diff line number Diff line change
1
+ function averageWaitingTime ( customers ) {
2
+ let [ tot , t ] = [ 0 , 0 ] ;
3
+ for ( const [ a , b ] of customers ) {
4
+ t = Math . max ( t , a ) + b ;
5
+ tot += t - a ;
6
+ }
7
+ return tot / customers . length ;
8
+ }
You can’t perform that action at this time.
0 commit comments