Skip to content

Commit aaa7e7e

Browse files
authored
feat: add new lc problems (doocs#1495)
1 parent 6ff5f4c commit aaa7e7e

File tree

84 files changed

+1571
-351
lines changed

Some content is hidden

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

84 files changed

+1571
-351
lines changed

solution/0100-0199/0137.Single Number II/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<p>给你一个整数数组&nbsp;<code>nums</code> ,除某个元素仅出现 <strong>一次</strong> 外,其余每个元素都恰出现 <strong>三次 。</strong>请你找出并返回那个只出现了一次的元素。</p>
1010

11-
<p>你必须设计并实现线性时间复杂度的算法且不使用额外空间来解决此问题。</p>
11+
<p>你必须设计并实现线性时间复杂度的算法且使用常数级空间来解决此问题。</p>
1212

1313
<p>&nbsp;</p>
1414

solution/0100-0199/0139.Word Break/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<li><code>1 &lt;= s.length &lt;= 300</code></li>
4545
<li><code>1 &lt;= wordDict.length &lt;= 1000</code></li>
4646
<li><code>1 &lt;= wordDict[i].length &lt;= 20</code></li>
47-
<li><code>s</code> 和 <code>wordDict[i]</code> 仅有小写英文字母组成</li>
47+
<li><code>s</code> 和 <code>wordDict[i]</code> 仅由小写英文字母组成</li>
4848
<li><code>wordDict</code> 中的所有字符串 <strong>互不相同</strong></li>
4949
</ul>
5050

solution/0100-0199/0175.Combine Two Tables/README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
| FirstName | varchar |
1717
| LastName | varchar |
1818
+-------------+---------+
19-
personId 是该表的主键列
19+
personId 是该表的主键(具有唯一值的列)
2020
该表包含一些人的 ID 和他们的姓和名的信息。
2121
</pre>
2222

@@ -33,15 +33,17 @@ personId 是该表的主键列。
3333
| City | varchar |
3434
| State | varchar |
3535
+-------------+---------+
36-
addressId 是该表的主键列
36+
addressId 是该表的主键(具有唯一值的列)
3737
该表的每一行都包含一个 ID = PersonId 的人的城市和州的信息。
3838
</pre>
3939

40-
<p>编写一个SQL查询来报告 <code>Person</code> 表中每个人的姓、名、城市和州。如果 <code>personId</code> 的地址不在&nbsp;<code>Address</code>&nbsp;表中,则报告为空 &nbsp;<code>null</code>&nbsp;。</p>
40+
<p>&nbsp;</p>
41+
42+
<p>编写解决方案,报告 <code>Person</code> 表中每个人的姓、名、城市和州。如果 <code>personId</code> 的地址不在&nbsp;<code>Address</code>&nbsp;表中,则报告为&nbsp;<code>null</code>&nbsp;。</p>
4143

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

44-
<p>查询结果格式如下所示。</p>
46+
<p>结果格式如下所示。</p>
4547

4648
<p>&nbsp;</p>
4749

solution/0100-0199/0181.Employees Earning More Than Their Managers/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
| salary | int |
1818
| managerId | int |
1919
+-------------+---------+
20-
Id是该表的主键
20+
id 是该表的主键(具有唯一值的列)
2121
该表的每一行都表示雇员的ID、姓名、工资和经理的ID。
2222
</pre>
2323

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

26-
<p>编写一个SQL查询来查找收入比经理高的员工。</p>
26+
<p>编写解决方案,找出收入比经理高的员工。</p>
2727

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

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

3232
<p>&nbsp;</p>
3333

solution/0100-0199/0182.Duplicate Emails/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
| id | int |
1818
| email | varchar |
1919
+-------------+---------+
20-
id 是该表的主键列
20+
id 是该表的主键(具有唯一值的列)
2121
此表的每一行都包含一封电子邮件。电子邮件不包含大写字母。
2222
</pre>
2323

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

26-
<p>编写一个 SQL 查询来报告所有重复的电子邮件。 请注意,可以保证电子邮件字段不为 NULL。</p>
26+
<p>编写解决方案来报告所有重复的电子邮件。 请注意,可以保证电子邮件字段不为 NULL。</p>
2727

2828
<p>以&nbsp;<strong>任意顺序&nbsp;</strong>返回结果表。</p>
2929

30-
<p>查询结果格式如下例。</p>
30+
<p>结果格式如下例。</p>
3131

3232
<p>&nbsp;</p>
3333

solution/0400-0499/0401.Binary Watch/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<li>For example, <code>&quot;01:00&quot;</code> is not valid. It should be <code>&quot;1:00&quot;</code>.</li>
2121
</ul>
2222

23-
<p>The minute must be consist of two digits and may contain a leading zero.</p>
23+
<p>The minute must&nbsp;consist of two digits and may contain a leading zero.</p>
2424

2525
<ul>
2626
<li>For example, <code>&quot;10:2&quot;</code> is not valid. It should be <code>&quot;10:02&quot;</code>.</li>

solution/0500-0599/0529.Minesweeper/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@
3232
<p>&nbsp;</p>
3333

3434
<p><strong>示例 1:</strong></p>
35-
<img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0500-0599/0529.Minesweeper/images/minesweeper_example_1.png" style="width: 500px; max-width: 400px; height: 269px;" />
35+
<img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0500-0599/0529.Minesweeper/images/untitled.jpeg" style="width: 500px; max-width: 400px; height: 269px;" />
3636
<pre>
3737
<strong>输入:</strong>board = [["E","E","E","E","E"],["E","E","M","E","E"],["E","E","E","E","E"],["E","E","E","E","E"]], click = [3,0]
3838
<strong>输出:</strong>[["B","1","E","1","B"],["B","1","M","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]]
3939
</pre>
4040

4141
<p><strong>示例 2:</strong></p>
42-
<img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0500-0599/0529.Minesweeper/images/minesweeper_example_2.png" style="width: 500px; max-width: 400px; height: 275px;" />
42+
<img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0500-0599/0529.Minesweeper/images/untitled-2.jpeg" style="width: 500px; max-width: 400px; height: 275px;" />
4343
<pre>
4444
<strong>输入:</strong>board = [["B","1","E","1","B"],["B","1","M","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]], click = [1,2]
4545
<strong>输出:</strong>[["B","1","E","1","B"],["B","1","X","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]]

solution/0500-0599/0534.Game Play Analysis III/README.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>Table:&nbsp;<code>Activity</code></p>
9+
<p>表:<code>Activity</code></p>
1010

1111
<pre>
1212
+--------------+---------+
@@ -17,18 +17,25 @@
1717
| event_date | date |
1818
| games_played | int |
1919
+--------------+---------+
20-
(player_id,event_date)是此表的主键。
20+
(player_id,event_date)是此表的主键(具有唯一值的列)
2121
这张表显示了某些游戏的玩家的活动情况。
2222
每一行是一个玩家的记录,他在某一天使用某个设备注销之前登录并玩了很多游戏(可能是 0 )。
2323
</pre>
2424

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

27-
<p>编写一个 SQL 查询,同时报告每组玩家和日期,以及玩家到目前为止玩了多少游戏。也就是说,在此日期之前玩家所玩的游戏总数。详细情况请查看示例。</p>
27+
<p>编写一个解决方案,同时报告每组玩家和日期,以及玩家到 <strong>目前为止</strong> 玩了多少游戏。也就是说,玩家在该日期之前所玩的游戏总数。详细情况请查看示例。</p>
2828

29-
<p>查询结果格式如下所示:</p>
29+
<p>以 <strong>任意顺序</strong> 返回结果表。</p>
30+
31+
<p>结果格式如下所示。</p>
32+
33+
<p>&nbsp;</p>
34+
35+
<p><strong>示例 1:</strong></p>
3036

3137
<pre>
38+
<strong>输入:</strong>
3239
Activity table:
3340
+-----------+-----------+------------+--------------+
3441
| player_id | device_id | event_date | games_played |
@@ -39,8 +46,7 @@ Activity table:
3946
| 3 | 1 | 2016-03-02 | 0 |
4047
| 3 | 4 | 2018-07-03 | 5 |
4148
+-----------+-----------+------------+--------------+
42-
43-
Result table:
49+
<strong>输出:</strong>
4450
+-----------+------------+---------------------+
4551
| player_id | event_date | games_played_so_far |
4652
+-----------+------------+---------------------+
@@ -50,6 +56,7 @@ Result table:
5056
| 3 | 2016-03-02 | 0 |
5157
| 3 | 2018-07-03 | 5 |
5258
+-----------+------------+---------------------+
59+
<strong>解释:</strong>
5360
对于 ID 为 1 的玩家,2016-05-02 共玩了 5+6=11 个游戏,2017-06-25 共玩了 5+6+1=12 个游戏。
5461
对于 ID 为 3 的玩家,2018-07-03 共玩了 0+5=5 个游戏。
5562
请注意,对于每个玩家,我们只关心玩家的登录日期。

solution/0500-0599/0550.Game Play Analysis IV/README.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,33 @@
88

99
<p>Table:&nbsp;<code>Activity</code></p>
1010

11-
<pre>+--------------+---------+
11+
<pre>
12+
+--------------+---------+
1213
| Column Name | Type |
1314
+--------------+---------+
1415
| player_id | int |
1516
| device_id | int |
1617
| event_date | date |
1718
| games_played | int |
1819
+--------------+---------+
19-
(player_id,event_date)是此表的主键。
20+
(player_id,event_date)是此表的主键(具有唯一值的列的组合)
2021
这张表显示了某些游戏的玩家的活动情况。
2122
每一行是一个玩家的记录,他在某一天使用某个设备注销之前登录并玩了很多游戏(可能是 0)。
2223
</pre>
2324

2425
<p>&nbsp;</p>
2526

26-
<p>编写一个 SQL 查询,报告在首次登录的第二天再次登录的玩家的比率,四舍五入到小数点后两位。换句话说,您需要计算从首次登录日期开始至少连续两天登录的玩家的数量,然后除以玩家总数。</p>
27+
<p>编写解决方案,报告在首次登录的第二天再次登录的玩家的 <strong>比率</strong>,<strong>四舍五入到小数点后两位</strong>。换句话说,你需要计算从首次登录日期开始至少连续两天登录的玩家的数量,然后除以玩家总数。</p>
28+
29+
<p>结果格式如下所示:</p>
2730

28-
<p>查询结果格式如下所示:</p>
31+
<p>&nbsp;</p>
2932

30-
<pre>Activity table:
33+
<p><strong>示例 1:</strong></p>
34+
35+
<pre>
36+
<strong>输入:</strong>
37+
Activity table:
3138
+-----------+-----------+------------+--------------+
3239
| player_id | device_id | event_date | games_played |
3340
+-----------+-----------+------------+--------------+
@@ -37,13 +44,13 @@
3744
| 3 | 1 | 2016-03-02 | 0 |
3845
| 3 | 4 | 2018-07-03 | 5 |
3946
+-----------+-----------+------------+--------------+
40-
41-
Result table:
47+
<strong>输出:</strong>
4248
+-----------+
4349
| fraction |
4450
+-----------+
4551
| 0.33 |
4652
+-----------+
53+
<strong>解释:</strong>
4754
只有 ID 为 1 的玩家在第一天登录后才重新登录,所以答案是 1/3 = 0.33
4855
</pre>
4956

solution/0500-0599/0580.Count Student Number in Departments/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
| gender | varchar |
1818
| dept_id | int |
1919
+--------------+---------+
20-
Student_id是该表的主键
20+
student_id 是该表的主键(具有唯一值的列)
2121
dept_id是Department表中dept_id的外键。
2222
该表的每一行都表示学生的姓名、性别和所属系的id。
2323
</pre>
@@ -33,16 +33,16 @@ dept_id是Department表中dept_id的外键。
3333
| dept_id | int |
3434
| dept_name | varchar |
3535
+-------------+---------+
36-
Dept_id是该表的主键
36+
dept_id是该表的主键(具有唯一值的列)
3737
该表的每一行包含一个部门的id和名称。</pre>
3838

3939
<p>&nbsp;</p>
4040

41-
<p>编写一个SQL查询,为&nbsp;<code>Department</code>&nbsp;表中的所有部门(甚至是没有当前学生的部门)报告各自的部门名称和每个部门的学生人数。</p>
41+
<p>编写解决方案,为&nbsp;<code>Department</code>&nbsp;表中的所有部门(甚至是没有当前学生的部门)报告各自的部门名称和每个部门的学生人数。</p>
4242

4343
<p>按 <code>student_number</code> <strong>降序&nbsp;</strong>返回结果表。如果是平局,则按 <code>dept_name</code> 的&nbsp; <strong>字母顺序&nbsp;</strong>排序。</p>
4444

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

4747
<p>&nbsp;</p>
4848

solution/0500-0599/0582.Kill Process/README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>系统中存在 <code>n</code> 个进程,形成一个有根树结构。给你两个整数数组 <code>pid</code> 和 <code>ppid</code> ,其中 <code>pid[i]</code> 是第 <code>i</code> 个进程的 ID ,<code>ppid[i]</code> 是第 <code>i</code> 个进程的父进程 ID 。</p>
9+
<p>系统中存在 <code>n</code>&nbsp;个进程,形成一个有根树结构。给你两个整数数组&nbsp;<code>pid</code> 和 <code>ppid</code> ,其中 <code>pid[i]</code> 是第 <code>i</code> 个进程的 ID ,<code>ppid[i]</code> 是第 <code>i</code> 个进程的父进程 ID 。</p>
1010

1111
<p>每一个进程只有 <strong>一个父进程</strong> ,但是可能会有 <strong>一个或者多个子进程</strong> 。只有一个进程的 <code>ppid[i] = 0</code> ,意味着这个进程 <strong>没有父进程</strong> 。</p>
1212

1313
<p>当一个进程 <strong>被杀掉</strong> 的时候,它所有的子进程和后代进程都要被杀掉。</p>
1414

15-
<p>给你一个整数 <code>kill</code> 表示要杀掉​​进程的 ID ,返回杀掉该进程后的所有进程 ID 的列表。可以按 <strong>任意顺序</strong> 返回答案。</p>
16-
 
15+
<p>给你一个整数 <code>kill</code> 表示要杀掉​​进程的 ID ,返回被杀掉的进程的 ID 列表。可以按 <strong>任意顺序</strong> 返回答案。</p>
16+
&nbsp;
1717

1818
<p><strong>示例 1:</strong></p>
1919
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0500-0599/0582.Kill%20Process/images/ptree.jpg" style="width: 207px; height: 302px;" />
@@ -30,16 +30,16 @@
3030
<strong>输出:</strong>[1]
3131
</pre>
3232

33-
<p> </p>
33+
<p>&nbsp;</p>
3434

3535
<p><strong>提示:</strong></p>
3636

3737
<ul>
3838
<li><code>n == pid.length</code></li>
3939
<li><code>n == ppid.length</code></li>
40-
<li><code>1 <= n <= 5 * 10<sup>4</sup></code></li>
41-
<li><code>1 <= pid[i] <= 5 * 10<sup>4</sup></code></li>
42-
<li><code>0 <= ppid[i] <= 5 * 10<sup>4</sup></code></li>
40+
<li><code>1 &lt;= n &lt;= 5 * 10<sup>4</sup></code></li>
41+
<li><code>1 &lt;= pid[i] &lt;= 5 * 10<sup>4</sup></code></li>
42+
<li><code>0 &lt;= ppid[i] &lt;= 5 * 10<sup>4</sup></code></li>
4343
<li>仅有一个进程没有父进程</li>
4444
<li><code>pid</code> 中的所有值 <strong>互不相同</strong></li>
4545
<li>题目数据保证 <code>kill</code> 在 <code>pid</code> 中</li>

solution/0600-0699/0620.Not Boring Movies/README.md

+28-11
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,36 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>某城市开了一家新的电影院,吸引了很多人过来看电影。该电影院特别注意用户体验,专门有个 LED显示板做电影推荐,上面公布着影评和相关电影描述。</p>
9+
<p>表:<code>cinema</code></p>
1010

11-
<p>作为该电影院的信息部主管,您需要编写一个 SQL查询,找出所有影片描述为<strong>非</strong>&nbsp;<code>boring</code>&nbsp;(不无聊)&nbsp;的并且<strong> id 为奇数&nbsp;</strong>的影片,结果请按等级 <code>rating</code> 排列。</p>
11+
<pre>
12+
+----------------+----------+
13+
| Column Name | Type |
14+
+----------------+----------+
15+
| id | int |
16+
| movie | varchar |
17+
| description | varchar |
18+
| rating | float |
19+
+----------------+----------+
20+
id 是该表的主键(具有唯一值的列)。
21+
每行包含有关电影名称、类型和评级的信息。
22+
评级为 [0,10] 范围内的小数点后 2 位浮点数。
23+
</pre>
24+
25+
<p>&nbsp;</p>
26+
27+
<p>编写解决方案,找出所有影片描述为&nbsp;<strong>非</strong>&nbsp;<code>boring</code>&nbsp;(不无聊)&nbsp;的并且<strong> id 为奇数&nbsp;</strong>的影片。</p>
28+
29+
<p>返回结果按&nbsp;<code>rating</code>&nbsp;<strong>降序排列</strong>。</p>
30+
31+
<p>结果格式如下示例。</p>
1232

1333
<p>&nbsp;</p>
1434

15-
<p>例如,下表 <code>cinema</code>:</p>
35+
<p><strong>示例 1:</strong></p>
1636

1737
<pre>
38+
<strong>输入:</strong>
1839
+---------+-----------+--------------+-----------+
1940
| id | movie | description | rating |
2041
+---------+-----------+--------------+-----------+
@@ -23,22 +44,18 @@
2344
| 3 | irish | boring | 6.2 |
2445
| 4 | Ice song | Fantacy | 8.6 |
2546
| 5 | House card| Interesting| 9.1 |
26-
+---------+-----------+--------------+-----------+
27-
</pre>
28-
29-
<p>对于上面的例子,则正确的输出是为:</p>
30-
31-
<pre>
47+
<strong>+---------+-----------+--------------+-----------+
48+
输出:</strong>
3249
+---------+-----------+--------------+-----------+
3350
| id | movie | description | rating |
3451
+---------+-----------+--------------+-----------+
3552
| 5 | House card| Interesting| 9.1 |
3653
| 1 | War | great 3D | 8.9 |
3754
+---------+-----------+--------------+-----------+
55+
<strong>解释:</strong>
56+
我们有三部电影,它们的 id 是奇数:1、3 和 5。id = 3 的电影是 boring 的,所以我们不把它包括在答案中。
3857
</pre>
3958

40-
<p>&nbsp;</p>
41-
4259
## 解法
4360

4461
<!-- 这里可写通用的实现逻辑 -->

solution/0600-0699/0627.Swap Salary/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
| sex | ENUM |
2020
| salary | int |
2121
+-------------+----------+
22-
id 是这个表的主键。
22+
id 是这个表的主键(具有唯一值的列)
2323
sex 这一列的值是 ENUM 类型,只能从 ('m', 'f') 中取。
2424
本表包含公司雇员的信息。
2525
</pre>
2626

2727
<p>&nbsp;</p>
2828

29-
<p>请你编写一个 SQL 查询来交换所有的 <code>'f'</code> 和 <code>'m'</code> (即,将所有 <code>'f'</code> 变为 <code>'m'</code> ,反之亦然),仅使用 <strong>单个 update 语句</strong> ,且不产生中间临时表。</p>
29+
<p>请你编写一个解决方案来交换所有的 <code>'f'</code> 和 <code>'m'</code> (即,将所有 <code>'f'</code> 变为 <code>'m'</code> ,反之亦然),仅使用 <strong>单个 update 语句</strong> ,且不产生中间临时表。</p>
3030

3131
<p>注意,你必须仅使用一条 update 语句,且 <strong>不能</strong> 使用 select 语句。</p>
3232

33-
<p>查询结果如下例所示。</p>
33+
<p>结果如下例所示。</p>
3434

3535
<p>&nbsp;</p>
3636

solution/0800-0899/0828.Count Unique Characters of All Substrings of a Given String/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Description
66

7-
<p>Let&#39;s define a function <code>countUniqueChars(s)</code> that returns the number of unique characters on <code>s</code>.</p>
7+
<p>Let&#39;s define a function <code>countUniqueChars(s)</code> that returns the number of unique characters in&nbsp;<code>s</code>.</p>
88

99
<ul>
1010
<li>For example, calling <code>countUniqueChars(s)</code> if <code>s = &quot;LEETCODE&quot;</code> then <code>&quot;L&quot;</code>, <code>&quot;T&quot;</code>, <code>&quot;C&quot;</code>, <code>&quot;O&quot;</code>, <code>&quot;D&quot;</code> are the unique characters since they appear only once in <code>s</code>, therefore <code>countUniqueChars(s) = 5</code>.</li>

0 commit comments

Comments
 (0)