Skip to content

Commit 2729a3c

Browse files
committed
feat: add typescript solution to lc problem: No.1266.Minimum Time Visiting All Points
1 parent c2db695 commit 2729a3c

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

solution/1200-1299/1266.Minimum Time Visiting All Points/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,20 @@ class Solution {
9595
}
9696
```
9797

98+
### **TypeScript**
99+
100+
```ts
101+
function minTimeToVisitAllPoints(points: number[][]): number {
102+
let ans = 0;
103+
for (let i = 1; i < points.length; i++) {
104+
let dx = Math.abs(points[i][0] - points[i - 1][0]),
105+
dy = Math.abs(points[i][1] - points[i - 1][1]);
106+
ans += Math.max(dx, dy);
107+
}
108+
return ans;
109+
}
110+
```
111+
98112
### **C++**
99113

100114
```cpp

solution/1200-1299/1266.Minimum Time Visiting All Points/README_EN.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ class Solution {
8181
}
8282
```
8383

84+
### **TypeScript**
85+
86+
```ts
87+
function minTimeToVisitAllPoints(points: number[][]): number {
88+
let ans = 0;
89+
for (let i = 1; i < points.length; i++) {
90+
let dx = Math.abs(points[i][0] - points[i - 1][0]),
91+
dy = Math.abs(points[i][1] - points[i - 1][1]);
92+
ans += Math.max(dx, dy);
93+
}
94+
return ans;
95+
}
96+
```
97+
8498
### **C++**
8599

86100
```cpp
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function minTimeToVisitAllPoints(points: number[][]): number {
2+
let ans = 0;
3+
for (let i = 1; i < points.length; i++) {
4+
let dx = Math.abs(points[i][0] - points[i - 1][0]),
5+
dy = Math.abs(points[i][1] - points[i - 1][1]);
6+
ans += Math.max(dx, dy);
7+
}
8+
return ans;
9+
}

0 commit comments

Comments
 (0)