Skip to content

Commit ad6703c

Browse files
committed
v2.5.2 - 更新了题库 - 538modified
1 parent 67c65cc commit ad6703c

File tree

538 files changed

+20458
-1225
lines changed

Some content is hidden

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

538 files changed

+20458
-1225
lines changed

AllProblems/1034.边界着色.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ tags: [题解, LeetCode, 中等, 深度优先搜索, 广度优先搜索, 数组,
1010

1111
<p>给你一个大小为 <code>m x n</code> 的整数矩阵 <code>grid</code> ,表示一个网格。另给你三个整数&nbsp;<code>row</code>、<code>col</code> 和 <code>color</code> 。网格中的每个值表示该位置处的网格块的颜色。</p>
1212

13-
<p>两个网格块属于同一 <strong>连通分量</strong> 需满足下述全部条件:</p>
13+
<p>如果两个方块在任意 4 个方向上相邻,则称它们&nbsp;<strong>相邻 </strong></p>
1414

15-
<ul>
16-
<li>两个网格块颜色相同</li>
17-
<li>在上、下、左、右任意一个方向上相邻</li>
18-
</ul>
15+
<p>如果两个方块具有相同的颜色且相邻,它们则属于同一个 <strong>连通分量</strong> 。</p>
1916

2017
<p><strong>连通分量的边界</strong><strong> </strong>是指连通分量中满足下述条件之一的所有网格块:</p>
2118

@@ -24,23 +21,25 @@ tags: [题解, LeetCode, 中等, 深度优先搜索, 广度优先搜索, 数组,
2421
<li>在网格的边界上(第一行/列或最后一行/列)</li>
2522
</ul>
2623

27-
<p>请你使用指定颜色&nbsp;<code>color</code> 为所有包含网格块&nbsp;<code>grid[row][col]</code> 的 <strong>连通分量的边界</strong> 进行着色,并返回最终的网格&nbsp;<code>grid</code> 。</p>
24+
<p>请你使用指定颜色&nbsp;<code>color</code> 为所有包含网格块&nbsp;<code>grid[row][col]</code> 的 <strong>连通分量的边界</strong> 进行着色。</p>
25+
26+
<p>并返回最终的网格&nbsp;<code>grid</code> 。</p>
2827

2928
<p>&nbsp;</p>
3029

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

3332
<pre>
3433
<strong>输入:</strong>grid = [[1,1],[1,2]], row = 0, col = 0, color = 3
3534
<strong>输出:</strong>[[3,3],[3,2]]</pre>
3635

37-
<p><strong>示例 2:</strong></p>
36+
<p><strong class="example">示例 2:</strong></p>
3837

3938
<pre>
4039
<strong>输入:</strong>grid = [[1,2,2],[2,3,2]], row = 0, col = 1, color = 3
4140
<strong>输出:</strong>[[1,3,3],[2,3,3]]</pre>
4241

43-
<p><strong>示例 3:</strong></p>
42+
<p><strong class="example">示例 3:</strong></p>
4443

4544
<pre>
4645
<strong>输入:</strong>grid = [[1,1,1],[1,1,1],[1,1,1]], row = 1, col = 1, color = 2
@@ -59,7 +58,5 @@ tags: [题解, LeetCode, 中等, 深度优先搜索, 广度优先搜索, 数组,
5958
<li><code>0 &lt;= col &lt; n</code></li>
6059
</ul>
6160

62-
<p>&nbsp;</p>
63-
6461

6562

AllProblems/104.二叉树的最大深度.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,38 @@ tags: [题解, LeetCode, 简单, 树, 深度优先搜索, 广度优先搜索,
88

99
力扣题目链接:[https://leetcode.cn/problems/maximum-depth-of-binary-tree/](https://leetcode.cn/problems/maximum-depth-of-binary-tree/)
1010

11-
<p>给定一个二叉树,找出其最大深度。</p>
11+
<p>给定一个二叉树 <code>root</code> ,返回其最大深度。</p>
1212

13-
<p>二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。</p>
13+
<p>二叉树的 <strong>最大深度</strong> 是指从根节点到最远叶子节点的最长路径上的节点数。</p>
1414

15-
<p><strong>说明:</strong>&nbsp;叶子节点是指没有子节点的节点。</p>
15+
<p>&nbsp;</p>
1616

17-
<p><strong>示例:</strong><br>
18-
给定二叉树 <code>[3,9,20,null,null,15,7]</code>,</p>
17+
<p><strong>示例 1:</strong></p>
1918

20-
<pre> 3
21-
/ \
22-
9 20
23-
/ \
24-
15 7</pre>
19+
<p><img alt="" src="https://assets.leetcode.com/uploads/2020/11/26/tmp-tree.jpg" style="width: 400px; height: 277px;" /></p>
2520

26-
<p>返回它的最大深度&nbsp;3 。</p>
21+
<p>&nbsp;</p>
22+
23+
<pre>
24+
<b>输入:</b>root = [3,9,20,null,null,15,7]
25+
<b>输出:</b>3
26+
</pre>
27+
28+
<p><strong>示例 2:</strong></p>
29+
30+
<pre>
31+
<b>输入:</b>root = [1,null,2]
32+
<b>输出:</b>2
33+
</pre>
34+
35+
<p>&nbsp;</p>
36+
37+
<p><strong>提示:</strong></p>
38+
39+
<ul>
40+
<li>树中节点的数量在&nbsp;<code>[0, 10<sup>4</sup>]</code>&nbsp;区间内。</li>
41+
<li><code>-100 &lt;= Node.val &lt;= 100</code></li>
42+
</ul>
2743

2844

2945

AllProblems/1045.买下所有产品的客户.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,44 @@ tags: [题解, LeetCode, 中等, 数据库]
1010

1111
<p><code>Customer</code>&nbsp;表:</p>
1212

13-
<pre>+-------------+---------+
13+
<pre>
14+
+-------------+---------+
1415
| Column Name | Type |
1516
+-------------+---------+
1617
| customer_id | int |
1718
| product_key | int |
1819
+-------------+---------+
19-
product_key 是 <code>Customer 表的外键</code>。
20+
该表可能包含重复的行。
21+
customer_id 不为 NULL。
22+
product_key 是 Product 表的外键(reference 列)。
2023
</pre>
2124

2225
<p><code>Product</code>&nbsp;表:</p>
2326

24-
<pre>+-------------+---------+
27+
<pre>
28+
+-------------+---------+
2529
| Column Name | Type |
2630
+-------------+---------+
2731
| product_key | int |
2832
+-------------+---------+
29-
product_key 是这张表的主键。
33+
product_key 是这张表的主键(具有唯一值的列)
3034
</pre>
3135

3236
<p>&nbsp;</p>
3337

34-
<p>写一条 SQL 查询语句,从 <code>Customer</code> 表中查询购买了 <code>Product</code> 表中所有产品的客户的 id。</p>
38+
<p>编写解决方案,报告&nbsp;<code>Customer</code> 表中购买了 <code>Product</code> 表中所有产品的客户的 id。</p>
39+
40+
<p>返回结果表 <strong>无顺序要求</strong> 。</p>
41+
42+
<p>返回结果格式如下所示。</p>
3543

36-
<p><strong>示例:</strong></p>
44+
<p>&nbsp;</p>
45+
46+
<p><strong>示例 1:</strong></p>
3747

38-
<pre>Customer 表:
48+
<pre>
49+
<strong>输入:</strong>
50+
Customer 表:
3951
+-------------+-------------+
4052
| customer_id | product_key |
4153
+-------------+-------------+
@@ -45,22 +57,21 @@ product_key 是这张表的主键。
4557
| 3 | 6 |
4658
| 1 | 6 |
4759
+-------------+-------------+
48-
4960
Product 表:
5061
+-------------+
5162
| product_key |
5263
+-------------+
5364
| 5 |
5465
| 6 |
5566
+-------------+
56-
57-
Result 表:
67+
<strong>输出:</strong>
5868
+-------------+
5969
| customer_id |
6070
+-------------+
6171
| 1 |
6272
| 3 |
6373
+-------------+
74+
<strong>解释:</strong>
6475
购买了所有产品(5 和 6)的客户的 id 是 1 和 3 。
6576
</pre>
6677

AllProblems/1050.合作过至少三次的演员和导演.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ tags: [题解, LeetCode, 简单, 数据库]
1818
| director_id | int |
1919
| timestamp | int |
2020
+-------------+---------+
21-
timestamp 是这张表的主键.
21+
timestamp 是这张表的主键(具有唯一值的列).
2222
</pre>
2323

2424
<p>&nbsp;</p>
2525

26-
<p>写一条SQL查询语句获取合作过至少三次的演员和导演的 id 对&nbsp;<code>(actor_id, director_id)</code></p>
26+
<p>编写解决方案找出合作过至少三次的演员和导演的 id 对&nbsp;<code>(actor_id, director_id)</code></p>
2727

28-
<p><strong>示例:</strong></p>
28+
<p>&nbsp;</p>
29+
30+
<p><strong>示例 1:</strong></p>
2931

3032
<pre>
33+
<strong>输入:</strong>
3134
ActorDirector 表:
3235
+-------------+-------------+-------------+
3336
| actor_id | director_id | timestamp |
@@ -40,13 +43,13 @@ ActorDirector 表:
4043
| 2 | 1 | 5 |
4144
| 2 | 1 | 6 |
4245
+-------------+-------------+-------------+
43-
44-
Result 表:
46+
<strong>输出:</strong>
4547
+-------------+-------------+
4648
| actor_id | director_id |
4749
+-------------+-------------+
4850
| 1 | 1 |
4951
+-------------+-------------+
52+
<strong>解释:</strong>
5053
唯一的 id 对是 (1, 1),他们恰好合作了 3 次。</pre>
5154

5255

AllProblems/1068.产品销售分析 I.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ tags: [题解, LeetCode, 简单, 数据库]
2020
| quantity | int |
2121
| price | int |
2222
+-------------+-------+
23-
(sale_id, year) 是销售表 Sales 的主键.
24-
product_id 是关联到产品表 Product 的外键.
25-
注意: price 表示每单位价格
23+
(sale_id, year) 是销售表 Sales 的主键(具有唯一值的列的组合)。
24+
product_id 是关联到产品表 Product 的外键(reference 列)。
25+
该表的每一行显示 product_id 在某一年的销售情况。
26+
注意: price 表示每单位价格。
2627
</pre>
2728

2829
<p>产品表&nbsp;<code>Product</code>:</p>
@@ -34,29 +35,32 @@ product_id 是关联到产品表 Product 的外键.
3435
| product_id | int |
3536
| product_name | varchar |
3637
+--------------+---------+
37-
product_id&nbsp;是表的主键.
38+
product_id&nbsp;是表的主键(具有唯一值的列)。
39+
该表的每一行表示每种产品的产品名称。
3840
</pre>
3941

4042
<p>&nbsp;</p>
4143

42-
<p>写一条SQL&nbsp;查询语句获取 <code>Sales</code>&nbsp;表中所有产品对应的 <strong>产品名称 product_name</strong> 以及该产品的所有 <strong>售卖年份 year</strong>&nbsp; <strong>价格 price</strong> 。</p>
44+
<p>编写解决方案,以获取 <code>Sales</code>&nbsp;表中所有 <code>sale_id</code> 对应的&nbsp;<code>product_name</code> 以及该产品的所有<strong>&nbsp;</strong><code>year</code>&nbsp;和<strong>&nbsp;</strong><code>price</code> 。</p>
4345

44-
<p>查询结果中的顺序无特定要求。</p>
46+
<p>返回结果表&nbsp;<strong>无顺序要求</strong> 。</p>
4547

46-
<p>查询结果格式示例如下:</p>
48+
<p>结果格式示例如下。</p>
4749

4850
<p>&nbsp;</p>
4951

52+
<p><strong>示例 1:</strong></p>
53+
5054
<pre>
51-
<code>Sales</code> 表:
55+
<code><strong>输入:</strong>
56+
Sales</code> 表:
5257
+---------+------------+------+----------+-------+
5358
| sale_id | product_id | year | quantity | price |
5459
+---------+------------+------+----------+-------+
5560
| 1 | 100 | 2008 | 10 | 5000 |
5661
| 2 | 100 | 2009 | 12 | 5000 |
5762
| 7 | 200 | 2011 | 15 | 9000 |
5863
+---------+------------+------+----------+-------+
59-
6064
Product 表:
6165
+------------+--------------+
6266
| product_id | product_name |
@@ -65,8 +69,7 @@ Product 表:
6569
| 200 | Apple |
6670
| 300 | Samsung |
6771
+------------+--------------+
68-
69-
Result 表:
72+
<strong>输出:</strong>
7073
+--------------+-------+-------+
7174
| product_name | year | price |
7275
+--------------+-------+-------+

AllProblems/1070.产品销售分析 III.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ tags: [题解, LeetCode, 中等, 数据库]
2020
| quantity | int |
2121
| price | int |
2222
+-------------+-------+
23-
(sale_id, year) 是这张表的主键。
24-
product_id 是产品表的外键。
23+
(sale_id, year) 是这张表的主键(具有唯一值的列的组合)
24+
product_id 是产品表的外键(reference 列)
2525
这张表的每一行都表示:编号 product_id 的产品在某一年的销售额。
2626
请注意,价格是按每单位计的。
2727
</pre>
@@ -37,16 +37,16 @@ product_id 是产品表的外键。
3737
| product_id | int |
3838
| product_name | varchar |
3939
+--------------+---------+
40-
product_id 是这张表的主键。
40+
product_id 是这张表的主键(具有唯一值的列)
4141
这张表的每一行都标识:每个产品的 id 和 产品名称。</pre>
4242

4343
<p>&nbsp;</p>
4444

45-
<p>编写一个 SQL 查询,选出每个销售产品&nbsp;<strong>第一年</strong> 销售的 <strong>产品 id</strong>、<strong>年份</strong>、<strong>数量&nbsp;</strong>和 <strong>价格</strong>。</p>
45+
<p>编写解决方案,选出每个售出过的产品&nbsp;<strong>第一年</strong> 销售的 <strong>产品 id</strong>、<strong>年份</strong>、<strong>数量&nbsp;</strong>和 <strong>价格</strong>。</p>
4646

4747
<p>结果表中的条目可以按 <strong>任意顺序</strong> 排列。</p>
4848

49-
<p>查询结果格式如下例所示:</p>
49+
<p>结果格式如下例所示:</p>
5050

5151
<p>&nbsp;</p>
5252

AllProblems/1081.不同字符的最小子序列.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ tags: [题解, LeetCode, 中等, 栈, 贪心, 字符串, 单调栈]
1010

1111
<p>返回 <code>s</code> 字典序最小的子序列,该子序列包含 <code>s</code> 的所有不同字符,且只包含一次。</p>
1212

13-
<p><strong>注意:</strong>该题与 316 <a href="https://leetcode.com/problems/remove-duplicate-letters/">https://leetcode.com/problems/remove-duplicate-letters/</a> 相同</p>
14-
15-
<p> </p>
13+
<p>&nbsp;</p>
1614

1715
<p><strong>示例 1:</strong></p>
1816

@@ -27,14 +25,18 @@ tags: [题解, LeetCode, 中等, 栈, 贪心, 字符串, 单调栈]
2725
<strong>输入:</strong><code>s = "cbacdcbc"</code>
2826
<strong>输出:</strong><code>"acdb"</code></pre>
2927

30-
<p> </p>
28+
<p>&nbsp;</p>
3129

3230
<p><strong>提示:</strong></p>
3331

3432
<ul>
35-
<li><code>1 <= s.length <= 1000</code></li>
33+
<li><code>1 &lt;= s.length &lt;= 1000</code></li>
3634
<li><code>s</code> 由小写英文字母组成</li>
3735
</ul>
3836

37+
<p>&nbsp;</p>
38+
39+
<p><strong>注意:</strong>该题与 316 <a href="https://leetcode.cn/problems/remove-duplicate-letters/">https://leetcode.cn/problems/remove-duplicate-letters/</a> 相同</p>
40+
3941

4042

AllProblems/1084.销售分析III.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tags: [题解, LeetCode, 简单, 数据库]
88

99
力扣题目链接:[https://leetcode.cn/problems/sales-analysis-iii/](https://leetcode.cn/problems/sales-analysis-iii/)
1010

11-
<p>Table:&nbsp;<code>Product</code></p>
11+
<p>表:&nbsp;<code>Product</code></p>
1212

1313
<pre>
1414
+--------------+---------+
@@ -18,11 +18,11 @@ tags: [题解, LeetCode, 简单, 数据库]
1818
| product_name | varchar |
1919
| unit_price | int |
2020
+--------------+---------+
21-
Product_id是该表的主键
21+
product_id 是该表的主键(具有唯一值的列)
2222
该表的每一行显示每个产品的名称和价格。
2323
</pre>
2424

25-
<p>Table:&nbsp;<code>Sales</code></p>
25+
<p>表:<code>Sales</code></p>
2626

2727
<pre>
2828
+-------------+---------+
@@ -35,18 +35,18 @@ Product_id是该表的主键。
3535
| quantity | int |
3636
| price | int |
3737
+------ ------+---------+
38-
这个表没有主键,它可以有重复的行
39-
product_id 是 Product 表的外键。
38+
这个表可能有重复的行
39+
product_id 是 Product 表的外键(reference 列)
4040
该表的每一行包含关于一个销售的一些信息。
4141
</pre>
4242

4343
<p>&nbsp;</p>
4444

45-
<p>编写一个SQL查询,报告<code>2019年春季</code>才售出的产品。即<strong>仅</strong>在<code><strong>2019-01-01</strong></code>至<code><strong>2019-03-31</strong></code>(含)之间出售的商品。</p>
45+
<p>编写解决方案,报告<code>2019年春季</code>才售出的产品。即<strong>仅</strong>在<code><strong>2019-01-01</strong></code>至<code><strong>2019-03-31</strong></code>(含)之间出售的商品。</p>
4646

4747
<p>以 <strong>任意顺序</strong> 返回结果表。</p>
4848

49-
<p>查询结果格式如下所示。</p>
49+
<p>结果格式如下所示。</p>
5050

5151
<p>&nbsp;</p>
5252

0 commit comments

Comments
 (0)