Skip to content

Commit 12f831a

Browse files
authored
feat: add new lc problems and solutions: No.2784~2791 (doocs#1276)
* No.2784. Check if Array is Good * No.2785. Sort Vowels in a String * No.2786. Visit Array Positions to Maximize Score * No.2787. Ways to Express an Integer as Sum of Powers * No.2788. Split Strings by Separator * No.2789. Largest Element in an Array after Merge Operations * No.2790. Maximum Number of Groups With Increasing Length * No.2791. Count Paths That Can Form a Palindrome in a Tree
1 parent b9960e5 commit 12f831a

File tree

133 files changed

+3706
-236
lines changed

Some content is hidden

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

133 files changed

+3706
-236
lines changed

solution/0100-0199/0176.Second Highest Salary/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
| id | int |
1818
| salary | int |
1919
+-------------+------+
20-
id 是这个表的主键。
20+
在 SQL 中,id 是这个表的主键。
2121
表的每一行包含员工的工资信息。
2222
</pre>
2323

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

26-
<p>编写一个 SQL 查询,获取并返回 <code>Employee</code>&nbsp;表中第二高的薪水 。如果不存在第二高的薪水,查询应该返回 <code>null</code> 。</p>
26+
<p>查询并返回 <code>Employee</code>&nbsp;表中第二高的薪水 。如果不存在第二高的薪水,查询应该返回 <code>null(Pandas 则返回 None)</code> 。</p>
2727

2828
<p>查询结果如下例所示。</p>
2929

solution/0100-0199/0176.Second Highest Salary/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
| id | int |
1414
| salary | int |
1515
+-------------+------+
16-
id is the primary key column for this table.
16+
In SQL, id is the primary key column for this table.
1717
Each row of this table contains information about the salary of an employee.
1818
</pre>
1919

2020
<p>&nbsp;</p>
2121

22-
<p>Find&nbsp;the second highest salary from the <code>Employee</code> table. If there is no second highest salary,&nbsp;return&nbsp;<code>null</code>.</p>
22+
<p>Find&nbsp;the second highest salary from the <code>Employee</code> table. If there is no second highest salary,&nbsp;return&nbsp;<code>null (return&nbsp;None in Pandas)</code>.</p>
2323

2424
<p>The result format is in the following example.</p>
2525

solution/0100-0199/0177.Nth Highest Salary/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
| id | int |
1616
| salary | int |
1717
+-------------+------+
18-
Id是该表的主键列
18+
在 SQL 中,id 是该表的主键
1919
该表的每一行都包含有关员工工资的信息。
2020
</pre>
2121

2222
<p>&nbsp;</p>
2323

24-
<p>编写一个SQL查询来报告 <code>Employee</code> 表中第 <code>n</code> 高的工资。如果没有第 <code>n</code> 个最高工资,查询应该报告为&nbsp;<code>null</code> 。</p>
24+
<p>查询&nbsp;<code>Employee</code> 表中第 <code>n</code> 高的工资。如果没有第 <code>n</code> 个最高工资,查询结果应该为&nbsp;<code>null</code> 。</p>
2525

2626
<p>查询结果格式如下所示。</p>
2727

solution/0100-0199/0177.Nth Highest Salary/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| id | int |
1414
| salary | int |
1515
+-------------+------+
16-
id is the primary key column for this table.
16+
In SQL, id is the primary key column for this table.
1717
Each row of this table contains information about the salary of an employee.
1818
</pre>
1919

solution/0100-0199/0178.Rank Scores/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
| id | int |
1616
| score | decimal |
1717
+-------------+---------+
18-
Id是该表的主键
19-
该表的每一行都包含了一场比赛的分数。Score是一个有两位小数点的浮点值
18+
在 SQL 中,id 是该表的主键
19+
该表的每一行都包含了一场比赛的分数。Score 是一个有两位小数点的浮点值
2020
</pre>
2121

2222
<p>&nbsp;</p>
2323

24-
<p>编写 SQL 查询对分数进行排序。排名按以下规则计算:</p>
24+
<p>查询并对分数进行排序。排名按以下规则计算:</p>
2525

2626
<ul>
2727
<li>分数应按从高到低排列。</li>

solution/0100-0199/0178.Rank Scores/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| id | int |
1414
| score | decimal |
1515
+-------------+---------+
16-
id is the primary key for this table.
16+
In SQL, id is the primary key for this table.
1717
Each row of this table contains the score of a game. Score is a floating point value with two decimal places.
1818
</pre>
1919

solution/0100-0199/0183.Customers Who Never Order/README.md

+46-17
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,68 @@
66

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

9-
<p>某网站包含两个表,<code>Customers</code> 表和 <code>Orders</code> 表。编写一个 SQL 查询,找出所有从不订购任何东西的客户。</p>
10-
119
<p><code>Customers</code> 表:</p>
1210

13-
<pre>+----+-------+
14-
| Id | Name |
11+
<pre>
12+
+-------------+---------+
13+
| Column Name | Type |
14+
+-------------+---------+
15+
| id | int |
16+
| name | varchar |
17+
+-------------+---------+
18+
在 SQL 中,id 是该表的主键。
19+
该表的每一行都表示客户的 ID 和名称。</pre>
20+
21+
<p><code>Orders</code> 表:</p>
22+
23+
<pre>
24+
+-------------+------+
25+
| Column Name | Type |
26+
+-------------+------+
27+
| id | int |
28+
| customerId | int |
29+
+-------------+------+
30+
在 SQL 中,id 是该表的主键。
31+
customerId 是 Customers 表中 ID 的外键( Pandas 中的连接键)。
32+
该表的每一行都表示订单的 ID 和订购该订单的客户的 ID。</pre>
33+
34+
<p>&nbsp;</p>
35+
36+
<p>找出所有从不点任何东西的顾客。</p>
37+
38+
<p>以 <strong>任意顺序</strong> 返回结果表。</p>
39+
40+
<p>结果格式如下所示。</p>
41+
42+
<p>&nbsp;</p>
43+
44+
<p><strong>示例 1:</strong></p>
45+
46+
<pre>
47+
<b>输入:</b>
48+
Customers table:
49+
+----+-------+
50+
| id | name |
1551
+----+-------+
1652
| 1 | Joe |
1753
| 2 | Henry |
1854
| 3 | Sam |
1955
| 4 | Max |
2056
+----+-------+
21-
</pre>
22-
23-
<p><code>Orders</code> 表:</p>
24-
25-
<pre>+----+------------+
26-
| Id | CustomerId |
57+
Orders table:
58+
+----+------------+
59+
| id | customerId |
2760
+----+------------+
2861
| 1 | 3 |
2962
| 2 | 1 |
3063
+----+------------+
31-
</pre>
32-
33-
<p>例如给定上述表格,你的查询应返回:</p>
34-
35-
<pre>+-----------+
64+
<b>输出:</b>
65+
+-----------+
3666
| Customers |
3767
+-----------+
3868
| Henry |
3969
| Max |
40-
+-----------+
41-
</pre>
70+
+-----------+</pre>
4271

4372
## 解法
4473

solution/0100-0199/0183.Customers Who Never Order/README_EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| id | int |
1414
| name | varchar |
1515
+-------------+---------+
16-
id is the primary key column for this table.
16+
In SQL, id is the primary key column for this table.
1717
Each row of this table indicates the ID and name of a customer.
1818
</pre>
1919

@@ -28,8 +28,8 @@ Each row of this table indicates the ID and name of a customer.
2828
| id | int |
2929
| customerId | int |
3030
+-------------+------+
31-
id is the primary key column for this table.
32-
customerId is a foreign key of the ID from the Customers table.
31+
In SQL, id is the primary key column for this table.
32+
customerId is a foreign key (join key in Pandas) of the ID from the Customers table.
3333
Each row of this table indicates the ID of an order and the ID of the customer who ordered it.
3434
</pre>
3535

solution/0100-0199/0184.Department Highest Salary/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
| salary | int |
1818
| departmentId | int |
1919
+--------------+---------+
20-
id是此表的主键列
21-
departmentId是Department表中ID的外键
22-
此表的每一行都表示员工的ID、姓名和工资。它还包含他们所在部门的ID
20+
在 SQL 中,id是此表的主键
21+
departmentId 是 Department 表中 id 的外键(在 Pandas 中称为 join key)
22+
此表的每一行都表示员工的 id、姓名和工资。它还包含他们所在部门的 id
2323
</pre>
2424

2525
<p>&nbsp;</p>
@@ -33,13 +33,13 @@ departmentId是Department表中ID的外键。
3333
| id | int |
3434
| name | varchar |
3535
+-------------+---------+
36-
id是此表的主键列
37-
此表的每一行都表示一个部门的ID及其名称
36+
在 SQL 中,id 是此表的主键列
37+
此表的每一行都表示一个部门的 id 及其名称
3838
</pre>
3939

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

42-
<p>编写SQL查询以查找每个部门中薪资最高的员工。<br />
42+
<p>查找出每个部门中薪资最高的员工。<br />
4343
按 <strong>任意顺序</strong> 返回结果表。<br />
4444
查询结果格式如下例所示。</p>
4545

solution/0100-0199/0184.Department Highest Salary/README_EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
| salary | int |
1616
| departmentId | int |
1717
+--------------+---------+
18-
id is the primary key column for this table.
19-
departmentId is a foreign key of the ID from the <code>Department </code>table.
18+
In SQL, id is the primary key column for this table.
19+
departmentId is a foreign key (join key in Pandas) of the ID from the <code>Department </code>table.
2020
Each row of this table indicates the ID, name, and salary of an employee. It also contains the ID of their department.
2121
</pre>
2222

@@ -31,7 +31,7 @@ Each row of this table indicates the ID, name, and salary of an employee. It als
3131
| id | int |
3232
| name | varchar |
3333
+-------------+---------+
34-
id is the primary key column for this table. It is guaranteed that department name is not <code>NULL.</code>
34+
In SQL, id is the primary key column for this table. It is guaranteed that department name is not <code>NULL.</code>
3535
Each row of this table indicates the ID of a department and its name.
3636
</pre>
3737

solution/0100-0199/0196.Delete Duplicate Emails/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
| id | int |
1616
| email | varchar |
1717
+-------------+---------+
18-
id是该表的主键列
18+
在 SQL 中,id 是该表的主键列
1919
该表的每一行包含一封电子邮件。电子邮件将不包含大写字母。
2020
</pre>
2121

solution/0100-0199/0196.Delete Duplicate Emails/README_EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
| id | int |
1414
| email | varchar |
1515
+-------------+---------+
16-
id is the primary key column for this table.
16+
In SQL, id is the primary key column for this table.
1717
Each row of this table contains an email. The emails will not contain uppercase letters.
1818
</pre>
1919

2020
<p>&nbsp;</p>
2121

2222
<p><strong>Delete</strong> all the duplicate emails, keeping only one unique email with the smallest <code>id</code>.</p>
2323

24-
<p>(For SQL users, please note that you are supposed to write a <code>DELETE</code> statement and not a <code>SELECT</code> one.)</p>
24+
<p>For SQL users, please note that you are supposed to write a <code>DELETE</code> statement and not a <code>SELECT</code> one.</p>
2525

26-
<p>(For Pandas users, please note that you are supposed to modify <code>Person</code> in place.)</p>
26+
<p>For Pandas users, please note that you are supposed to modify <code>Person</code> in place.</p>
2727

2828
<p>After running your script, the answer shown is the <code>Person</code> table. The driver will first compile and run your piece of code and then show the <code>Person</code> table. The final order of the <code>Person</code> table <strong>does not matter</strong>.</p>
2929

solution/0300-0399/0395.Longest Substring with At Least K Repeating Characters/README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

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

9-
<p>给你一个字符串 <code>s</code> 和一个整数 <code>k</code> ,请你找出 <code>s</code> 中的最长子串, 要求该子串中的每一字符出现次数都不少于 <code>k</code> 。返回这一子串的长度。</p>
9+
<p>给你一个字符串 <code>s</code> 和一个整数 <code>k</code> ,请你找出 <code>s</code> 中的最长子串,&nbsp;要求该子串中的每一字符出现次数都不少于 <code>k</code> 。返回这一子串的长度。</p>
1010

11-
<p> </p>
11+
<p data-pm-slice="1 1 []">如果不存在这样的子字符串,则返回 0。</p>
12+
13+
<p>&nbsp;</p>
1214

1315
<p><strong>示例 1:</strong></p>
1416

@@ -25,14 +27,14 @@
2527
<strong>输出:</strong>5
2628
<strong>解释:</strong>最长子串为 "ababb" ,其中 'a' 重复了 2 次, 'b' 重复了 3 次。</pre>
2729

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

3032
<p><strong>提示:</strong></p>
3133

3234
<ul>
33-
<li><code>1 <= s.length <= 10<sup>4</sup></code></li>
35+
<li><code>1 &lt;= s.length &lt;= 10<sup>4</sup></code></li>
3436
<li><code>s</code> 仅由小写英文字母组成</li>
35-
<li><code>1 <= k <= 10<sup>5</sup></code></li>
37+
<li><code>1 &lt;= k &lt;= 10<sup>5</sup></code></li>
3638
</ul>
3739

3840
## 解法

solution/0300-0399/0395.Longest Substring with At Least K Repeating Characters/README_EN.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
<p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the length of the longest substring of</em> <code>s</code> <em>such that the frequency of each character in this substring is greater than or equal to</em> <code>k</code>.</p>
88

9+
<p data-pm-slice="1 1 []">if no such substring exists, return 0.</p>
10+
911
<p>&nbsp;</p>
1012
<p><strong class="example">Example 1:</strong></p>
1113

solution/0500-0599/0511.Game Play Analysis I/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
| event_date | date |
1818
| games_played | int |
1919
+--------------+---------+
20-
表的主键是 (player_id, event_date)。
20+
在 SQL 中,表的主键是 (player_id, event_date)。
2121
这张表展示了一些游戏玩家在游戏平台上的行为活动。
2222
每行数据记录了一名玩家在退出平台之前,当天使用同一台设备登录平台后打开的游戏的数目(可能是 0 个)。
2323
</pre>
2424

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

27-
<p>写一条 SQL&nbsp;查询语句获取每位玩家 <strong>第一次登陆平台的日期</strong>。</p>
27+
<p>查询每位玩家 <strong>第一次登陆平台的日期</strong>。</p>
2828

2929
<p>查询结果的格式如下所示:</p>
3030

solution/0500-0599/0511.Game Play Analysis I/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
| event_date | date |
1616
| games_played | int |
1717
+--------------+---------+
18-
(player_id, event_date) is the primary key of this table.
18+
In SQL, (player_id, event_date) is the primary key of this table.
1919
This table shows the activity of players of some games.
2020
Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on someday using some device.
2121
</pre>

solution/0500-0599/0570.Managers with at Least 5 Direct Reports/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
| department | varchar |
1818
| managerId | int |
1919
+-------------+---------+
20-
Id是该表的主键列
20+
在 SQL 中,id 是该表的主键列
2121
该表的每一行都表示雇员的名字、他们的部门和他们的经理的id。
2222
如果managerId为空,则该员工没有经理。
2323
没有员工会成为自己的管理者。
2424
</pre>
2525

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

28-
<p>编写一个SQL查询,查询<strong>至少有5名直接下属</strong>的经理<strong> </strong>。</p>
28+
<p>查询<strong>至少有5名直接下属</strong>的经理<strong> </strong>。</p>
2929

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

solution/0500-0599/0570.Managers with at Least 5 Direct Reports/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
| department | varchar |
1616
| managerId | int |
1717
+-------------+---------+
18-
id is the primary key column for this table.
18+
In SQL, id is the primary key column for this table.
1919
Each row of this table indicates the name of an employee, their department, and the id of their manager.
2020
If managerId is null, then the employee does not have a manager.
2121
No employee will be the manager of themself.

solution/0500-0599/0586.Customer Placing the Largest Number of Orders/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
| order_number | int |
1616
| customer_number | int |
1717
+-----------------+----------+
18-
Order_number是该表的主键。
18+
在 SQL 中,Order_number是该表的主键。
1919
此表包含关于订单ID和客户ID的信息。
2020
</pre>
2121

2222
<p>&nbsp;</p>
2323

24-
<p>编写一个SQL查询,为下了 <strong>最多订单</strong> 的客户查找 <code>customer_number</code> 。</p>
24+
<p>查找下了 <strong>最多订单</strong>&nbsp;的客户的 <code>customer_number</code> 。</p>
2525

2626
<p>测试用例生成后, <strong>恰好有一个客户</strong> 比任何其他客户下了更多的订单。</p>
2727

solution/0500-0599/0586.Customer Placing the Largest Number of Orders/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| order_number | int |
1414
| customer_number | int |
1515
+-----------------+----------+
16-
order_number is the primary key for this table.
16+
In SQL, order_number is the primary key for this table.
1717
This table contains information about the order ID and the customer ID.
1818
</pre>
1919

0 commit comments

Comments
 (0)