Skip to content

Commit e43dd02

Browse files
committed
feat: add solutions to lc problem: No.1637
No.1637.Widest Vertical Area Between Two Points Containing No Points
1 parent 526b902 commit e43dd02

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

solution/1600-1699/1636.Sort Array by Increasing Frequency/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@
4646

4747
**方法一:数组或哈希表计数**
4848

49-
用数组或者哈希表统计 `nums` 中每个数字出现的次数,由于题目中数字的范围是 `[-100, 100]`,我们可以直接创建一个大小为 $201$ 的数组来统计。
49+
用数组或者哈希表统计 `nums` 中每个数字出现的次数,由于题目中数字的范围是 $[-100, 100]$,我们可以直接创建一个大小为 $201$ 的数组来统计。
5050

5151
然后对 `nums` 按照数字出现次数升序排序,如果出现次数相同,则按照数字降序排序。
5252

53-
时间复杂度为 $O(n\log n)$,空间复杂度 $O(n)$。其中 $n$ `nums` 的长度。
53+
时间复杂度为 $O(n \times \log n)$,空间复杂度 $O(n)$。其中 $n$ 为数组 `nums` 的长度。
5454

5555
<!-- tabs:start -->
5656

solution/1600-1699/1637.Widest Vertical Area Between Two Points Containing No Points/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
**方法一:排序**
4848

49-
`points` 按照 $x$ 升序排列,获取相邻点之间 $x$ 的差值的最大值。
49+
我们可以对 `points` 按照 $x$ 升序排列,获取相邻点之间 $x$ 的差值的最大值。
5050

5151
时间复杂度 $O(n \times \log n)$,空间复杂度 $O(\log n)$。其中 $n$ 为 `points` 的长度。
5252

@@ -115,6 +115,19 @@ func max(a, b int) int {
115115
}
116116
```
117117

118+
### **TypeScript**
119+
120+
```ts
121+
function maxWidthOfVerticalArea(points: number[][]): number {
122+
points.sort((a, b) => a[0] - b[0]);
123+
let ans = 0;
124+
for (let i = 1; i < points.length; ++i) {
125+
ans = Math.max(ans, points[i][0] - points[i - 1][0]);
126+
}
127+
return ans;
128+
}
129+
```
130+
118131
### **JavaScript**
119132

120133
```js

solution/1600-1699/1637.Widest Vertical Area Between Two Points Containing No Points/README_EN.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ func max(a, b int) int {
9999
}
100100
```
101101

102+
### **TypeScript**
103+
104+
```ts
105+
function maxWidthOfVerticalArea(points: number[][]): number {
106+
points.sort((a, b) => a[0] - b[0]);
107+
let ans = 0;
108+
for (let i = 1; i < points.length; ++i) {
109+
ans = Math.max(ans, points[i][0] - points[i - 1][0]);
110+
}
111+
return ans;
112+
}
113+
```
114+
102115
### **JavaScript**
103116

104117
```js
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function maxWidthOfVerticalArea(points: number[][]): number {
2+
points.sort((a, b) => a[0] - b[0]);
3+
let ans = 0;
4+
for (let i = 1; i < points.length; ++i) {
5+
ans = Math.max(ans, points[i][0] - points[i - 1][0]);
6+
}
7+
return ans;
8+
}

0 commit comments

Comments
 (0)