Skip to content

Commit 29a6b6f

Browse files
committed
feat: update lc problems
1 parent 13ca332 commit 29a6b6f

File tree

86 files changed

+1062
-1151
lines changed

Some content is hidden

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

86 files changed

+1062
-1151
lines changed

solution/0100-0199/0134.Gas Station/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ tags:
5757
<p><strong>提示:</strong></p>
5858

5959
<ul>
60-
<li><code>gas.length == n</code></li>
61-
<li><code>cost.length == n</code></li>
60+
<li><code>n == gas.length == cost.length</code></li>
6261
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
6362
<li><code>0 &lt;= gas[i], cost[i] &lt;= 10<sup>4</sup></code></li>
63+
<li>输入保证答案唯一。</li>
6464
</ul>
6565

6666
<!-- description:end -->

solution/0100-0199/0134.Gas Station/README_EN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Therefore, you can&#39;t travel around the circuit once no matter where you star
6060
<li><code>n == gas.length == cost.length</code></li>
6161
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
6262
<li><code>0 &lt;= gas[i], cost[i] &lt;= 10<sup>4</sup></code></li>
63+
<li>The input is generated such that the answer is unique.</li>
6364
</ul>
6465

6566
<!-- description:end -->

solution/0100-0199/0195.Tenth Line/README_EN.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,26 @@ tags:
2323
<p>Assume that <code>file.txt</code> has the following content:</p>
2424

2525
<pre>
26-
2726
Line 1
28-
2927
Line 2
30-
3128
Line 3
32-
3329
Line 4
34-
3530
Line 5
36-
3731
Line 6
38-
3932
Line 7
40-
4133
Line 8
42-
4334
Line 9
44-
4535
Line 10
46-
4736
</pre>
4837

4938
<p>Your script should output the tenth line, which is:</p>
5039

5140
<pre>
52-
5341
Line 10
54-
5542
</pre>
5643

5744
<div class="spoilers"><b>Note:</b><br />
58-
5945
1. If the file contains less than 10 lines, what should you output?<br />
60-
6146
2. There&#39;s at least three different solutions. Try to explore all possibilities.</div>
6247

6348
<!-- description:end -->

solution/0200-0299/0262.Trips and Users/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ id 是这张表的主键(具有唯一值的列)。
3636
status 是一个表示行程状态的枚举类型,枚举成员为(‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’) 。
3737
</pre>
3838

39-
<p>&nbsp;</p>
40-
4139
<div class="original__bRMd">
4240
<div>
4341
<p>表:<code>Users</code></p>
@@ -57,8 +55,6 @@ users_id 是这张表的主键(具有唯一值的列)。
5755
banned 是一个表示用户是否被禁止的枚举类型,枚举成员为 (‘Yes’, ‘No’) 。
5856
</pre>
5957

60-
<p>&nbsp;</p>
61-
6258
<p><strong>取消率</strong> 的计算方式如下:(被司机或乘客取消的非禁止用户生成的订单数量) / (非禁止用户生成的订单总数)。</p>
6359

6460
<p>编写解决方案找出&nbsp;<code>"2013-10-01"</code><strong>&nbsp;</strong>至&nbsp;<code>"2013-10-03"</code><strong>&nbsp;</strong>期间有&nbsp;<strong>至少&nbsp;</strong>一次行程的非禁止用户(<strong>乘客和司机都必须未被禁止</strong>)的 <strong>取消率</strong>。非禁止用户即 banned 为 No 的用户,禁止用户即 banned 为 Yes 的用户。其中取消率 <code>Cancellation Rate</code> 需要四舍五入保留 <strong>两位小数</strong> 。</p>

solution/0200-0299/0262.Trips and Users/README_EN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The table holds all taxi trips. Each trip has a unique id, while client_id and d
3434
Status is an ENUM (category) type of (&#39;completed&#39;, &#39;cancelled_by_driver&#39;, &#39;cancelled_by_client&#39;).
3535
</pre>
3636

37-
<p>&nbsp;</p>
37+
<p> </p>
3838

3939
<p>Table: <code>Users</code></p>
4040

@@ -51,15 +51,15 @@ The table holds all users. Each user has a unique users_id, and role is an ENUM
5151
banned is an ENUM (category) type of (&#39;Yes&#39;, &#39;No&#39;).
5252
</pre>
5353

54-
<p>&nbsp;</p>
54+
<p> </p>
5555

5656
<p>The <strong>cancellation rate</strong> is computed by dividing the number of canceled (by client or driver) requests with unbanned users by the total number of requests with unbanned users on that day.</p>
5757

5858
<p>Write a solution to find the <strong>cancellation rate</strong> of requests with unbanned users (<strong>both client and driver must not be banned</strong>) each day between <code>&quot;2013-10-01&quot;</code> and <code>&quot;2013-10-03&quot;</code> with <strong>at least</strong> one trip. Round <code>Cancellation Rate</code> to <strong>two decimal</strong> points.</p>
5959

6060
<p>Return the result table in <strong>any order</strong>.</p>
6161

62-
<p>The&nbsp;result format is in the following example.</p>
62+
<p>The result format is in the following example.</p>
6363

6464
<p>&nbsp;</p>
6565
<p><strong class="example">Example 1:</strong></p>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
comments: true
3+
difficulty: 简单
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0500-0599/0596.Classes%20More%20Than%205%20Students/README.md
5+
tags:
6+
- 数据库
7+
---
8+
9+
<!-- problem:start -->
10+
11+
# [596. 超过 5 名学生的课](https://leetcode.cn/problems/classes-more-than-5-students)
12+
13+
[English Version](/solution/0500-0599/0596.Classes%20More%20Than%205%20Students/README_EN.md)
14+
15+
## 题目描述
16+
17+
<!-- description:start -->
18+
19+
<p>表:&nbsp;<code>Courses</code></p>
20+
21+
<pre>
22+
+-------------+---------+
23+
| Column Name | Type |
24+
+-------------+---------+
25+
| student | varchar |
26+
| class | varchar |
27+
+-------------+---------+
28+
(student, class)是该表的主键(不同值的列的组合)。
29+
该表的每一行表示学生的名字和他们注册的班级。
30+
</pre>
31+
32+
<p>&nbsp;</p>
33+
34+
<p>查询&nbsp;<strong>至少有 5 个学生</strong> 的所有班级。</p>
35+
36+
<p>以 <strong>任意顺序 </strong>返回结果表。</p>
37+
38+
<p>结果格式如下所示。</p>
39+
40+
<p>&nbsp;</p>
41+
42+
<p><strong class="example">示例 1:</strong></p>
43+
44+
<pre>
45+
<strong>输入:</strong>
46+
Courses table:
47+
+---------+----------+
48+
| student | class |
49+
+---------+----------+
50+
| A | Math |
51+
| B | English |
52+
| C | Math |
53+
| D | Biology |
54+
| E | Math |
55+
| F | Computer |
56+
| G | Math |
57+
| H | Math |
58+
| I | Math |
59+
+---------+----------+
60+
<strong>输出:</strong>
61+
+---------+
62+
| class &nbsp; |
63+
+---------+
64+
| Math &nbsp; &nbsp;|
65+
+---------+
66+
<strong>解释: </strong>
67+
-数学课有 6 个学生,所以我们包括它。
68+
-英语课有 1 名学生,所以我们不包括它。
69+
-生物课有 1 名学生,所以我们不包括它。
70+
-计算机课有 1 个学生,所以我们不包括它。</pre>
71+
72+
<!-- description:end -->
73+
74+
## 解法
75+
76+
<!-- solution:start -->
77+
78+
### 方法一
79+
80+
<!-- tabs:start -->
81+
82+
#### MySQL
83+
84+
```sql
85+
86+
```
87+
88+
<!-- tabs:end -->
89+
90+
<!-- solution:end -->
91+
92+
<!-- problem:end -->
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
comments: true
3+
difficulty: Easy
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0500-0599/0596.Classes%20More%20Than%205%20Students/README_EN.md
5+
tags:
6+
- Database
7+
---
8+
9+
<!-- problem:start -->
10+
11+
# [596. Classes More Than 5 Students](https://leetcode.com/problems/classes-more-than-5-students)
12+
13+
[中文文档](/solution/0500-0599/0596.Classes%20More%20Than%205%20Students/README.md)
14+
15+
## Description
16+
17+
<!-- description:start -->
18+
19+
<p>Table: <code>Courses</code></p>
20+
21+
<pre>
22+
+-------------+---------+
23+
| Column Name | Type |
24+
+-------------+---------+
25+
| student | varchar |
26+
| class | varchar |
27+
+-------------+---------+
28+
(student, class) is the primary key (combination of columns with unique values) for this table.
29+
Each row of this table indicates the name of a student and the class in which they are enrolled.
30+
</pre>
31+
32+
<p>&nbsp;</p>
33+
34+
<p>Write a solution to find all the classes that have <strong>at least five students</strong>.</p>
35+
36+
<p>Return the result table in <strong>any order</strong>.</p>
37+
38+
<p>The&nbsp;result format is in the following example.</p>
39+
40+
<p>&nbsp;</p>
41+
<p><strong class="example">Example 1:</strong></p>
42+
43+
<pre>
44+
<strong>Input:</strong>
45+
Courses table:
46+
+---------+----------+
47+
| student | class |
48+
+---------+----------+
49+
| A | Math |
50+
| B | English |
51+
| C | Math |
52+
| D | Biology |
53+
| E | Math |
54+
| F | Computer |
55+
| G | Math |
56+
| H | Math |
57+
| I | Math |
58+
+---------+----------+
59+
<strong>Output:</strong>
60+
+---------+
61+
| class |
62+
+---------+
63+
| Math |
64+
+---------+
65+
<strong>Explanation:</strong>
66+
- Math has 6 students, so we include it.
67+
- English has 1 student, so we do not include it.
68+
- Biology has 1 student, so we do not include it.
69+
- Computer has 1 student, so we do not include it.
70+
</pre>
71+
72+
<!-- description:end -->
73+
74+
## Solutions
75+
76+
<!-- solution:start -->
77+
78+
### Solution 1
79+
80+
<!-- tabs:start -->
81+
82+
#### MySQL
83+
84+
```sql
85+
86+
```
87+
88+
<!-- tabs:end -->
89+
90+
<!-- solution:end -->
91+
92+
<!-- problem:end -->

solution/0700-0799/0799.Champagne Tower/README_EN.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,51 +27,35 @@ tags:
2727
<p>Now after pouring some non-negative integer cups of champagne, return how full the <code>j<sup>th</sup></code> glass in the <code>i<sup>th</sup></code> row is (both <code>i</code> and <code>j</code> are 0-indexed.)</p>
2828

2929
<p>&nbsp;</p>
30-
3130
<p><strong class="example">Example 1:</strong></p>
3231

3332
<pre>
34-
3533
<strong>Input:</strong> poured = 1, query_row = 1, query_glass = 1
36-
3734
<strong>Output:</strong> 0.00000
38-
3935
<strong>Explanation:</strong> We poured 1 cup of champange to the top glass of the tower (which is indexed as (0, 0)). There will be no excess liquid so all the glasses under the top glass will remain empty.
40-
4136
</pre>
4237

4338
<p><strong class="example">Example 2:</strong></p>
4439

4540
<pre>
46-
4741
<strong>Input:</strong> poured = 2, query_row = 1, query_glass = 1
48-
4942
<strong>Output:</strong> 0.50000
50-
5143
<strong>Explanation:</strong> We poured 2 cups of champange to the top glass of the tower (which is indexed as (0, 0)). There is one cup of excess liquid. The glass indexed as (1, 0) and the glass indexed as (1, 1) will share the excess liquid equally, and each will get half cup of champange.
52-
5344
</pre>
5445

5546
<p><strong class="example">Example 3:</strong></p>
5647

5748
<pre>
58-
5949
<strong>Input:</strong> poured = 100000009, query_row = 33, query_glass = 17
60-
6150
<strong>Output:</strong> 1.00000
62-
6351
</pre>
6452

6553
<p>&nbsp;</p>
66-
6754
<p><strong>Constraints:</strong></p>
6855

6956
<ul>
70-
71-
<li><code>0 &lt;=&nbsp;poured &lt;= 10<sup>9</sup></code></li>
72-
73-
<li><code>0 &lt;= query_glass &lt;= query_row&nbsp;&lt; 100</code></li>
74-
57+
<li><code>0 &lt;=&nbsp;poured &lt;= 10<sup>9</sup></code></li>
58+
<li><code>0 &lt;= query_glass &lt;= query_row&nbsp;&lt; 100</code></li>
7559
</ul>
7660

7761
<!-- description:end -->

solution/1000-1099/1016.Binary String With Substrings Representing 1 To N/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1000-1099/1016.Bi
55
rating: 1779
66
source: 第 129 场周赛 Q4
77
tags:
8+
- 位运算
9+
- 哈希表
810
- 字符串
11+
- 滑动窗口
912
---
1013

1114
<!-- problem:start -->

solution/1000-1099/1016.Binary String With Substrings Representing 1 To N/README_EN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1000-1099/1016.Bi
55
rating: 1779
66
source: Weekly Contest 129 Q4
77
tags:
8+
- Bit Manipulation
9+
- Hash Table
810
- String
11+
- Sliding Window
912
---
1013

1114
<!-- problem:start -->

solution/1000-1099/1062.Longest Repeating Substring/README.md

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

1414
<!-- problem:start -->
1515

16-
# [1062. 最长重复子串 🔒](https://leetcode.cn/problems/longest-repeating-substring)
16+
# [1062. 最长重复子串的长度 🔒](https://leetcode.cn/problems/longest-repeating-substring)
1717

1818
[English Version](/solution/1000-1099/1062.Longest%20Repeating%20Substring/README_EN.md)
1919

0 commit comments

Comments
 (0)