Skip to content

Commit 98852a2

Browse files
authored
feat: update lc problems (#4698)
1 parent ac0cf6e commit 98852a2

File tree

50 files changed

+232
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+232
-153
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
*.iml
77
__pycache__
88
/node_modules
9-
/solution/result.json
109
/solution/__pycache__
1110
/solution/.env
1211
.cache
1312
!.cache/plugin/
1413
!.cache/plugin/git-committers/
15-
!.cache/plugin/git-committers/page-authors.json
14+
!.cache/plugin/git-committers/page-authors.json

solution/0000-0099/0045.Jump Game II/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tags:
1818

1919
<!-- description:start -->
2020

21-
<p>给定一个长度为 <code>n</code> 的 <strong>0 索引</strong>整数数组 <code>nums</code>。初始位置为 <code>nums[0]</code>。</p>
21+
<p>给定一个长度为 <code>n</code> 的 <strong>0 索引</strong>整数数组 <code>nums</code>。初始位置在下标 0。</p>
2222

2323
<p>每个元素 <code>nums[i]</code> 表示从索引 <code>i</code> 向后跳转的最大长度。换句话说,如果你在索引&nbsp;<code>i</code>&nbsp;处,你可以跳转到任意 <code>(i + j)</code> 处:</p>
2424

solution/0000-0099/0056.Merge Intervals/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ tags:
3636
<strong>输出:</strong>[[1,5]]
3737
<strong>解释:</strong>区间 [1,4] 和 [4,5] 可被视为重叠区间。</pre>
3838

39+
<p><strong class="example">示例 3:</strong></p>
40+
41+
<pre>
42+
<b>输入:</b>intervals = [[4,7],[1,4]]
43+
<b>输出:</b>[[1,7]]
44+
<b>解释:</b>区间 [1,4] 和 [4,7] 可被视为重叠区间。
45+
</pre>
46+
3947
<p>&nbsp;</p>
4048

4149
<p><strong>提示:</strong></p>

solution/0000-0099/0056.Merge Intervals/README_EN.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ tags:
3636
<strong>Explanation:</strong> Intervals [1,4] and [4,5] are considered overlapping.
3737
</pre>
3838

39+
<p><strong class="example">Example 3:</strong></p>
40+
41+
<pre>
42+
<strong>Input:</strong> intervals = [[4,7],[1,4]]
43+
<strong>Output:</strong> [[1,7]]
44+
<strong>Explanation:</strong> Intervals [1,4] and [4,7] are considered overlapping.
45+
</pre>
46+
3947
<p>&nbsp;</p>
4048
<p><strong>Constraints:</strong></p>
4149

solution/0100-0199/0130.Surrounded Regions/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ tags:
3737
<p><strong class="example">示例 1:</strong></p>
3838

3939
<div class="example-block">
40-
<p><strong>输入:</strong><span class="example-io">board = [["X","X","X","X"],["X","O","O","X"],["X","X","O","X"],["X","O","X","X"]]</span></p>
40+
<p><strong>输入:</strong><span class="example-io">board = [['X','X','X','X'],['X','O','O','X'],['X','X','O','X'],['X','O','X','X']]</span></p>
4141

42-
<p><b>输出:</b><span class="example-io">[["X","X","X","X"],["X","X","X","X"],["X","X","X","X"],["X","O","X","X"]]</span></p>
42+
<p><b>输出:</b><span class="example-io">[['X','X','X','X'],['X','X','X','X'],['X','X','X','X'],['X','O','X','X']]</span></p>
4343

4444
<p><strong>解释:</strong></p>
4545
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0130.Surrounded%20Regions/images/1718167191-XNjUTG-image.png" style="width: 367px; height: 158px;" />
@@ -49,9 +49,9 @@ tags:
4949
<p><strong class="example">示例 2:</strong></p>
5050

5151
<div class="example-block">
52-
<p><strong>输入:</strong><span class="example-io">board = [["X"]]</span></p>
52+
<p><strong>输入:</strong><span class="example-io">board = [['X']]</span></p>
5353

54-
<p><strong>输出:</strong><span class="example-io">[["X"]]</span></p>
54+
<p><strong>输出:</strong><span class="example-io">[['X']]</span></p>
5555
</div>
5656

5757
<p>&nbsp;</p>

solution/0200-0299/0200.Number of Islands/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ tags:
2020

2121
<!-- description:start -->
2222

23-
<p>给你一个由 <code>'1'</code>(陆地)和 <code>'0'</code>(水)组成的的二维网格,请你计算网格中岛屿的数量。</p>
23+
<p>给你一个由&nbsp;<code>'1'</code>(陆地)和 <code>'0'</code>(水)组成的的二维网格,请你计算网格中岛屿的数量。</p>
2424

2525
<p>岛屿总是被水包围,并且每座岛屿只能由水平方向和/或竖直方向上相邻的陆地连接形成。</p>
2626

2727
<p>此外,你可以假设该网格的四条边均被水包围。</p>
2828

29-
<p> </p>
29+
<p>&nbsp;</p>
3030

3131
<p><strong>示例 1:</strong></p>
3232

3333
<pre>
3434
<strong>输入:</strong>grid = [
35-
["1","1","1","1","0"],
36-
["1","1","0","1","0"],
37-
["1","1","0","0","0"],
38-
["0","0","0","0","0"]
35+
&nbsp; ['1','1','1','1','0'],
36+
&nbsp; ['1','1','0','1','0'],
37+
&nbsp; ['1','1','0','0','0'],
38+
&nbsp; ['0','0','0','0','0']
3939
]
4040
<strong>输出:</strong>1
4141
</pre>
@@ -44,22 +44,22 @@ tags:
4444

4545
<pre>
4646
<strong>输入:</strong>grid = [
47-
["1","1","0","0","0"],
48-
["1","1","0","0","0"],
49-
["0","0","1","0","0"],
50-
["0","0","0","1","1"]
47+
&nbsp; ['1','1','0','0','0'],
48+
&nbsp; ['1','1','0','0','0'],
49+
&nbsp; ['0','0','1','0','0'],
50+
&nbsp; ['0','0','0','1','1']
5151
]
5252
<strong>输出:</strong>3
5353
</pre>
5454

55-
<p> </p>
55+
<p>&nbsp;</p>
5656

5757
<p><strong>提示:</strong></p>
5858

5959
<ul>
6060
<li><code>m == grid.length</code></li>
6161
<li><code>n == grid[i].length</code></li>
62-
<li><code>1 <= m, n <= 300</code></li>
62+
<li><code>1 &lt;= m, n &lt;= 300</code></li>
6363
<li><code>grid[i][j]</code> 的值为 <code>'0'</code> 或 <code>'1'</code></li>
6464
</ul>
6565

solution/0200-0299/0223.Rectangle Area/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ tags:
4949
<p><strong>提示:</strong></p>
5050

5151
<ul>
52-
<li><code>-10<sup>4</sup> &lt;= ax1, ay1, ax2, ay2, bx1, by1, bx2, by2 &lt;= 10<sup>4</sup></code></li>
52+
<li><code>-10<sup>4</sup> &lt;= ax1 &lt;= ax2 &lt;= 10<sup>4</sup></code></li>
53+
<li><code>-10<sup>4</sup> &lt;= ay1 &lt;= ay2 &lt;= 10<sup>4</sup></code></li>
54+
<li><code>-10<sup>4</sup> &lt;= bx1 &lt;= bx2 &lt;= 10<sup>4</sup></code></li>
55+
<li><code>-10<sup>4</sup> &lt;= by1 &lt;= by2 &lt;= 10<sup>4</sup></code></li>
5356
</ul>
5457

5558
<!-- description:end -->

solution/0300-0399/0334.Increasing Triplet Subsequence/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ tags:
4343
<pre>
4444
<strong>输入:</strong>nums = [2,1,5,0,4,6]
4545
<strong>输出:</strong>true
46-
<strong>解释:</strong>三元组 (3, 4, 5) 满足题意,因为 nums[3] == 0 &lt; nums[4] == 4 &lt; nums[5] == 6
46+
<strong>解释:</strong>其中一个满足题意的三元组是 (3, 4, 5),因为 nums[3] == 0 &lt; nums[4] == 4 &lt; nums[5] == 6
4747
</pre>
4848

4949
<p>&nbsp;</p>

solution/0300-0399/0334.Increasing Triplet Subsequence/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tags:
4141
<pre>
4242
<strong>Input:</strong> nums = [2,1,5,0,4,6]
4343
<strong>Output:</strong> true
44-
<strong>Explanation:</strong> The triplet (3, 4, 5) is valid because nums[3] == 0 &lt; nums[4] == 4 &lt; nums[5] == 6.
44+
<strong>Explanation:</strong> One of the valid triplet is (3, 4, 5), because nums[3] == 0 &lt; nums[4] == 4 &lt; nums[5] == 6.
4545
</pre>
4646

4747
<p>&nbsp;</p>

solution/0300-0399/0347.Top K Frequent Elements/README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,45 @@ tags:
2525

2626
<p>给你一个整数数组 <code>nums</code> 和一个整数 <code>k</code> ,请你返回其中出现频率前 <code>k</code> 高的元素。你可以按 <strong>任意顺序</strong> 返回答案。</p>
2727

28-
<p> </p>
28+
<p>&nbsp;</p>
2929

30-
<p><strong>示例 1:</strong></p>
30+
<p><strong class="example">示例 1</strong></p>
3131

32-
<pre>
33-
<strong>输入: </strong>nums = [1,1,1,2,2,3], k = 2
34-
<strong>输出: </strong>[1,2]
35-
</pre>
32+
<div class="example-block">
33+
<p><span class="example-io"><b>输入:</b>nums = [1,1,1,2,2,3], k = 2</span></p>
3634

37-
<p><strong>示例 2:</strong></p>
35+
<p><strong>输出:</strong><span class="example-io">[1,2]</span></p>
36+
</div>
3837

39-
<pre>
40-
<strong>输入: </strong>nums = [1], k = 1
41-
<strong>输出: </strong>[1]</pre>
38+
<p><strong class="example">示例 2:</strong></p>
4239

43-
<p> </p>
40+
<div class="example-block">
41+
<p><span class="example-io"><b>输入:</b>nums = [1], k = 1</span></p>
42+
43+
<p><span class="example-io"><b>输出:</b>[1]</span></p>
44+
</div>
45+
46+
<p><strong class="example">示例 3:</strong></p>
47+
48+
<div class="example-block">
49+
<p><span class="example-io"><b>输入:</b>nums = [1,2,1,2,1,2,3,1,3,2], k = 2</span></p>
50+
51+
<p><strong>输出:</strong><span class="example-io">[1,2]</span></p>
52+
</div>
53+
54+
<p>&nbsp;</p>
4455

4556
<p><strong>提示:</strong></p>
4657

4758
<ul>
48-
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
59+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
4960
<li><code>k</code> 的取值范围是 <code>[1, 数组中不相同的元素的个数]</code></li>
5061
<li>题目数据保证答案唯一,换句话说,数组中前 <code>k</code> 个高频元素的集合是唯一的</li>
5162
</ul>
5263

53-
<p> </p>
64+
<p>&nbsp;</p>
5465

55-
<p><strong>进阶:</strong>你所设计算法的时间复杂度 <strong>必须</strong> 优于 <code>O(n log n)</code> ,其中 <code>n</code><em> </em>是数组大小。</p>
66+
<p><strong>进阶:</strong>你所设计算法的时间复杂度 <strong>必须</strong> 优于 <code>O(n log n)</code> ,其中 <code>n</code><em>&nbsp;</em>是数组大小。</p>
5667

5768
<!-- description:end -->
5869

0 commit comments

Comments
 (0)