Skip to content

Commit 0e0add0

Browse files
authored
feat: add ts solution to lc problem: No.1701 (doocs#2510)
No.1701.Average Waiting Time
1 parent ca86e35 commit 0e0add0

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
.vscode
44
.temp
55
.cache
6+
*.iml
7+
__pycache__
68
/node_modules
79
/solution/result.json
810
/solution/__pycache__
9-
/solution/.env
10-
*.iml
11+
/solution/.env

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

+11
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ func averageWaitingTime(customers [][]int) float64 {
125125
}
126126
```
127127

128+
```ts
129+
function averageWaitingTime(customers: number[][]): number {
130+
let [tot, t] = [0, 0];
131+
for (const [a, b] of customers) {
132+
t = Math.max(t, a) + b;
133+
tot += t - a;
134+
}
135+
return tot / customers.length;
136+
}
137+
```
138+
128139
<!-- tabs:end -->
129140

130141
<!-- end -->

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

+11
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,17 @@ func averageWaitingTime(customers [][]int) float64 {
121121
}
122122
```
123123

124+
```ts
125+
function averageWaitingTime(customers: number[][]): number {
126+
let [tot, t] = [0, 0];
127+
for (const [a, b] of customers) {
128+
t = Math.max(t, a) + b;
129+
tot += t - a;
130+
}
131+
return tot / customers.length;
132+
}
133+
```
134+
124135
<!-- tabs:end -->
125136

126137
<!-- end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function averageWaitingTime(customers: number[][]): number {
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+
}

0 commit comments

Comments
 (0)