Skip to content

Commit 7315928

Browse files
authored
chore: update lc problems (#1563)
1 parent 255c50f commit 7315928

File tree

25 files changed

+106
-98
lines changed

25 files changed

+106
-98
lines changed

solution/0000-0099/0080.Remove Duplicates from Sorted Array II/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ for (int i = 0; i < len; i++) {
3838
<pre>
3939
<strong>输入:</strong>nums = [1,1,1,2,2,3]
4040
<strong>输出:</strong>5, nums = [1,1,2,2,3]
41-
<strong>解释:</strong>函数应返回新长度 length = <strong><code>5</code></strong>, 并且原数组的前五个元素被修改为 <strong><code>1, 1, 2, 2,</code></strong> <strong>3 </strong>。 不需要考虑数组中超出新长度后面的元素。
41+
<strong>解释:</strong>函数应返回新长度 length = <strong><code>5</code></strong>, 并且原数组的前五个元素被修改为 <strong><code>1, 1, 2, 2, 3</code></strong>。 不需要考虑数组中超出新长度后面的元素。
4242
</pre>
4343

4444
<p><strong>示例 2:</strong></p>
4545

4646
<pre>
4747
<strong>输入:</strong>nums = [0,0,1,1,1,1,2,3,3]
4848
<strong>输出:</strong>7, nums = [0,0,1,1,2,3,3]
49-
<strong>解释:</strong>函数应返回新长度 length = <strong><code>7</code></strong>, 并且原数组的前五个元素被修改为&nbsp;<strong><code>0</code></strong>, <strong>0</strong>, <strong>1</strong>, <strong>1</strong>, <strong>2</strong>, <strong>3</strong>, <strong>3 。</strong> 不需要考虑数组中超出新长度后面的元素。
49+
<strong>解释:</strong>函数应返回新长度 length = <strong><code>7</code></strong>, 并且原数组的前五个元素被修改为&nbsp;<strong><code>0, 0, 1, 1, 2, 3, 3</code></strong>不需要考虑数组中超出新长度后面的元素。
5050
</pre>
5151

5252
<p>&nbsp;</p>

solution/0300-0399/0373.Find K Pairs with Smallest Sums/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<li><code>1 &lt;= nums1.length, nums2.length &lt;= 10<sup>5</sup></code></li>
4949
<li><code>-10<sup>9</sup> &lt;= nums1[i], nums2[i] &lt;= 10<sup>9</sup></code></li>
5050
<li><code>nums1</code> 和 <code>nums2</code> 均为升序排列</li>
51-
<li><code>1 &lt;= k &lt;= 1000</code></li>
51+
<li><code>1 &lt;= k &lt;= 10<sup>4</sup></code></li>
5252
</ul>
5353

5454
## 解法

solution/1100-1199/1174.Immediate Food Delivery II/README_EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
| order_date | date |
1616
| customer_pref_delivery_date | date |
1717
+-----------------------------+---------+
18-
delivery_id is the primary key of this table.
18+
delivery_id is the column of unique values of this table.
1919
The table holds information about food delivery to customers that make orders at some date and specify a preferred delivery date (on the same order date or after it).
2020
</pre>
2121

@@ -25,9 +25,9 @@ The table holds information about food delivery to customers that make orders at
2525

2626
<p>The <strong>first order</strong> of a customer is the order with the earliest order date that the customer made. It is guaranteed that a customer has precisely one first order.</p>
2727

28-
<p>Write an SQL query to find the percentage of immediate orders in the first orders of all customers, <strong>rounded to 2 decimal places</strong>.</p>
28+
<p>Write a solution to find the percentage of immediate orders in the first orders of all customers, <strong>rounded to 2 decimal places</strong>.</p>
2929

30-
<p>The query result format is in the following example.</p>
30+
<p>The&nbsp;result format is in the following example.</p>
3131

3232
<p>&nbsp;</p>
3333
<p><strong class="example">Example 1:</strong></p>

solution/1200-1299/1204.Last Person to Fit in the Bus/README_EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
| weight | int |
1616
| turn | int |
1717
+-------------+---------+
18-
person_id is the primary key column for this table.
18+
person_id column contains unique values.
1919
This table has the information about all people waiting for a bus.
2020
The person_id and turn columns will contain all numbers from 1 to n, where n is the number of rows in the table.
2121
turn determines the order of which the people will board the bus, where turn=1 denotes the first person to board and turn=n denotes the last person to board.
@@ -26,9 +26,9 @@ weight is the weight of the person in kilograms.
2626

2727
<p>There is a queue of people waiting to board a bus. However, the bus has a weight limit of <code>1000</code><strong> kilograms</strong>, so there may be some people who cannot board.</p>
2828

29-
<p>Write an SQL query to find the <code>person_name</code> of the <strong>last person</strong> that can fit on the bus without exceeding the weight limit. The test cases are generated such that the first person does not exceed the weight limit.</p>
29+
<p>Write a solution to find the <code>person_name</code> of the <strong>last person</strong> that can fit on the bus without exceeding the weight limit. The test cases are generated such that the first person does not exceed the weight limit.</p>
3030

31-
<p>The query result format is in the following example.</p>
31+
<p>The&nbsp;result format is in the following example.</p>
3232

3333
<p>&nbsp;</p>
3434
<p><strong class="example">Example 1:</strong></p>

solution/1200-1299/1211.Queries Quality and Percentage/README_EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
| position | int |
1616
| rating | int |
1717
+-------------+---------+
18-
There is no primary key for this table, it may have duplicate rows.
18+
This table may have duplicate rows.
1919
This table contains information collected from some queries on a database.
2020
The <code>position</code> column has a value from <strong>1</strong> to <strong>500</strong>.
2121
The <code>rating</code> column has a value from <strong>1</strong> to <strong>5</strong>. Query with <code>rating</code> less than 3 is a poor query.
@@ -35,13 +35,13 @@ The <code>rating</code> column has a value from <strong>1</strong> to <strong>5<
3535
<p>The percentage of all queries with rating less than 3.</p>
3636
</blockquote>
3737

38-
<p>Write an SQL query to find each <code>query_name</code>, the <code>quality</code> and <code>poor_query_percentage</code>.</p>
38+
<p>Write a solution to find each <code>query_name</code>, the <code>quality</code> and <code>poor_query_percentage</code>.</p>
3939

4040
<p>Both <code>quality</code> and <code>poor_query_percentage</code> should be <strong>rounded to 2 decimal places</strong>.</p>
4141

4242
<p>Return the result table in <strong>any order</strong>.</p>
4343

44-
<p>The query result format is in the following example.</p>
44+
<p>The&nbsp;result format is in the following example.</p>
4545

4646
<p>&nbsp;</p>
4747
<p><strong class="example">Example 1:</strong></p>

solution/1200-1299/1212.Team Scores in Football Tournament/README_EN.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| team_id | int |
1414
| team_name | varchar |
1515
+---------------+----------+
16-
team_id is the primary key of this table.
16+
team_id is the column with unique values of this table.
1717
Each row of this table represents a single football team.
1818
</pre>
1919

@@ -31,7 +31,7 @@ Each row of this table represents a single football team.
3131
| host_goals | int |
3232
| guest_goals | int |
3333
+---------------+---------+
34-
match_id is the primary key of this table.
34+
match_id is the column of unique values of this table.
3535
Each row is a record of a finished match between two different teams.
3636
Teams host_team and guest_team are represented by their IDs in the Teams table (team_id), and they scored host_goals and guest_goals goals, respectively.
3737
</pre>
@@ -45,11 +45,11 @@ You would like to compute the scores of all teams after all matches. Points are
4545
<li>A team receives <strong>no points</strong> if they lose a match (i.e., Scored fewer goals than the opponent team).</li>
4646
</ul>
4747

48-
<p>Write an SQL query that selects the <code>team_id</code>, <code>team_name</code> and <code>num_points</code> of each team in the tournament after all described matches.</p>
48+
<p>Write a solution that selects the <code>team_id</code>, <code>team_name</code> and <code>num_points</code> of each team in the tournament after all described matches.</p>
4949

5050
<p>Return the result table ordered by <code>num_points</code> <strong>in decreasing order</strong>. In case of a tie, order the records by <code>team_id</code> <strong>in increasing order</strong>.</p>
5151

52-
<p>The query result format is in the following example.</p>
52+
<p>The result format is in the following example.</p>
5353

5454
<p>&nbsp;</p>
5555
<p><strong class="example">Example 1:</strong></p>

solution/1200-1299/1264.Page Recommendations/README_EN.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| user1_id | int |
1414
| user2_id | int |
1515
+---------------+---------+
16-
(user1_id, user2_id) is the primary key for this table.
16+
(user1_id, user2_id) is the primary key (combination of columns with unique values) for this table.
1717
Each row of this table indicates that there is a friendship relation between user1_id and user2_id.
1818
</pre>
1919

@@ -28,17 +28,17 @@ Each row of this table indicates that there is a friendship relation between use
2828
| user_id | int |
2929
| page_id | int |
3030
+-------------+---------+
31-
(user_id, page_id) is the primary key for this table.
31+
(user_id, page_id) is the primary key (combination of columns with unique values) for this table.
3232
Each row of this table indicates that user_id likes page_id.
3333
</pre>
3434

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

37-
<p>Write an SQL query to recommend pages to the user with <code>user_id = 1</code> using the pages that your friends liked. It should not recommend pages you already liked.</p>
37+
<p>Write a solution&nbsp;to recommend pages to the user with <code>user_id = 1</code> using the pages that your friends liked. It should not recommend pages you already liked.</p>
3838

3939
<p>Return result table in <strong>any order</strong> without duplicates.</p>
4040

41-
<p>The query result format is in the following example.</p>
41+
<p>The&nbsp;result format is in the following example.</p>
4242

4343
<p>&nbsp;</p>
4444
<p><strong class="example">Example 1:</strong></p>

solution/1200-1299/1270.All People Report to the Given Manager/README_EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414
| employee_name | varchar |
1515
| manager_id | int |
1616
+---------------+---------+
17-
employee_id is the primary key for this table.
17+
employee_id is the column of unique values for this table.
1818
Each row of this table indicates that the employee with ID employee_id and name employee_name reports his work to his/her direct manager with manager_id
1919
The head of the company is the employee with employee_id = 1.
2020
</pre>
2121

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

24-
<p>Write an SQL query to find <code>employee_id</code> of all employees that directly or indirectly report their work to the head of the company.</p>
24+
<p>Write a solution to find <code>employee_id</code> of all employees that directly or indirectly report their work to the head of the company.</p>
2525

2626
<p>The indirect relation between managers <strong>will not exceed three managers</strong> as the company is small.</p>
2727

2828
<p>Return the result table in <strong>any order</strong>.</p>
2929

30-
<p>The query result format is in the following example.</p>
30+
<p>The&nbsp;result format is in the following example.</p>
3131

3232
<p>&nbsp;</p>
3333
<p><strong class="example">Example 1:</strong></p>

solution/1200-1299/1285.Find the Start and End Number of Continuous Ranges/README_EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
+---------------+---------+
1313
| log_id | int |
1414
+---------------+---------+
15-
log_id is the primary key for this table.
15+
log_id is the column of unique values for this table.
1616
Each row of this table contains the ID in a log Table.
1717
</pre>
1818

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

21-
<p>Write an SQL query to find the start and end number of continuous ranges in the table <code>Logs</code>.</p>
21+
<p>Write a solution to find the start and end number of continuous ranges in the table <code>Logs</code>.</p>
2222

2323
<p>Return the result table ordered by <code>start_id</code>.</p>
2424

25-
<p>The query result format is in the following example.</p>
25+
<p>The result format is in the following example.</p>
2626

2727
<p>&nbsp;</p>
2828
<p><strong class="example">Example 1:</strong></p>

solution/1300-1399/1326.Minimum Number of Taps to Open to Water a Garden/README_EN.md

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

55
## Description
66

7-
<p>There is a one-dimensional garden on the x-axis. The garden starts at the point <code>0</code> and ends at the point <code>n</code>. (i.e The length of the garden is <code>n</code>).</p>
7+
<p>There is a one-dimensional garden on the x-axis. The garden starts at the point <code>0</code> and ends at the point <code>n</code>. (i.e., the&nbsp;length of the garden is <code>n</code>).</p>
88

99
<p>There are <code>n + 1</code> taps located at points <code>[0, 1, ..., n]</code> in the garden.</p>
1010

solution/1700-1799/1724.Checking Existence of Edge Length Limited Paths II/README.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@
66

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

9-
<p>一张有 <code>n</code> 个节点的无向图以边的列表 <code>edgeList</code> 的形式定义,其中 <code>edgeList[i] = [u<sub>i</sub>, v<sub>i</sub>, dis<sub>i</sub>]</code> 表示一条连接 <code>u<sub>i</sub></code> 和 <code>v<sub>i</sub></code> ,距离为 <code>dis<sub>i</sub></code> 的边。注意,同一对节点间可能有<strong>多条</strong>边,且该图可能不是连通的。</p>
9+
<p>一张有&nbsp;<code>n</code>&nbsp;个节点的无向图以边的列表&nbsp;<code>edgeList</code>&nbsp;的形式定义,其中&nbsp;<code>edgeList[i] = [u<sub>i</sub>, v<sub>i</sub>, dis<sub>i</sub>]</code>&nbsp;表示一条连接&nbsp;<code>u<sub>i</sub></code>&nbsp;&nbsp;<code>v<sub>i</sub></code>&nbsp;,距离为&nbsp;<code>dis<sub>i</sub></code>&nbsp;的边。注意,同一对节点间可能有<strong>多条</strong>边,且该图可能不是连通的。</p>
1010

11-
<p>实现 <code>DistanceLimitedPathsExist</code> 类:</p>
11+
<p>实现&nbsp;<code>DistanceLimitedPathsExist</code>&nbsp;类:</p>
1212

1313
<ul>
14-
<li><code>DistanceLimitedPathsExist(int n, int[][] edgeList)</code> 以给定的无向图初始化对象。</li>
15-
<li><code>boolean query(int p, int q, int limit)</code> 当存在一条从 <code>p</code> 到 <code>q</code> 的路径,且路径中每条边的距离都<strong>严格小于</strong> <code>limit</code> 时,返回 <code>true</code> ,否则返回 <code>false</code> 。</li>
14+
<li><code>DistanceLimitedPathsExist(int n, int[][] edgeList)</code>&nbsp;以给定的无向图初始化对象。</li>
15+
<li><code>boolean query(int p, int q, int limit)</code>&nbsp;当存在一条从&nbsp;<code>p</code>&nbsp;到 <code>q</code> 的路径,且路径中每条边的距离都<strong>严格小于</strong> <code>limit</code> 时,返回 <code>true</code> ,否则返回 <code>false</code> 。</li>
1616
</ul>
1717

18-
<p> </p>
18+
<p>&nbsp;</p>
1919

2020
<p><b>示例 1:</b></p>
2121

22-
<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1700-1799/1724.Checking%20Existence%20of%20Edge%20Length%20Limited%20Paths%20II/images/messed.png" style="width: 300px; height: 298px;"></strong></p>
22+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1700-1799/1724.Checking%20Existence%20of%20Edge%20Length%20Limited%20Paths%20II/images/1693449815-oSOAxI-%E6%88%AA%E5%B1%8F2023-08-31%2010.43.30.png){:width=400}" style="width: 400px;" /><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1700-1799/1724.Checking%20Existence%20of%20Edge%20Length%20Limited%20Paths%20II/images/1693449815-oSOAxI-%E6%88%AA%E5%B1%8F2023-08-31%2010.43.30.png" style="width: 400px; height: 352px;" /></p>
2323

24-
<pre><b>输入:</b>
24+
<pre>
25+
<b>输入:</b>
2526
["DistanceLimitedPathsExist", "query", "query", "query", "query"]
2627
[[6, [[0, 2, 4], [0, 3, 2], [1, 2, 3], [2, 3, 1], [4, 5, 5]]], [2, 3, 2], [1, 3, 3], [2, 0, 3], [0, 5, 6]]
2728
<b>输出:</b>
@@ -30,15 +31,15 @@
3031
<b>解释:</b>
3132
DistanceLimitedPathsExist distanceLimitedPathsExist = new DistanceLimitedPathsExist(6, [[0, 2, 4], [0, 3, 2], [1, 2, 3], [2, 3, 1], [4, 5, 5]]);
3233
distanceLimitedPathsExist.query(2, 3, 2); // 返回 true。存在一条从 2 到 3 ,距离为 1 的边,
33-
  // 这条边的距离小于 2。
34+
&nbsp; // 这条边的距离小于 2。
3435
distanceLimitedPathsExist.query(1, 3, 3); // 返回 false。从 1 到 3 之间不存在每条边的距离都
3536
// <strong>严格</strong>小于 3 的路径。
3637
distanceLimitedPathsExist.query(2, 0, 3); // 返回 true。存在一条从 2 到 0 的路径,使得每条边的
3738
// 距离 &lt; 3:从 2 到 3 到 0 行进即可。
3839
distanceLimitedPathsExist.query(0, 5, 6); // 返回 false。从 0 到 5 之间不存在路径。
3940
</pre>
4041

41-
<p> </p>
42+
<p>&nbsp;</p>
4243

4344
<p><strong>提示:</strong></p>
4445

@@ -50,7 +51,7 @@ distanceLimitedPathsExist.query(0, 5, 6); // 返回 false。从 0 到 5 之间
5051
<li><code>u<sub>i</sub> != v<sub>i</sub></code></li>
5152
<li><code>p != q</code></li>
5253
<li><code>1 &lt;= dis<sub>i</sub>, limit &lt;= 10<sup>9</sup></code></li>
53-
<li>最多调用 <code>10<sup>4</sup></code> 次 <code>query</code> 。</li>
54+
<li>最多调用&nbsp;<code>10<sup>4</sup></code>&nbsp;次&nbsp;<code>query</code>&nbsp;。</li>
5455
</ul>
5556

5657
## 解法

solution/1800-1899/1846.Maximum Element After Decreasing and Rearranging/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function maximumElementAfterDecrementingAndRearranging(arr: number[]): number {
163163
ans = Math.max(ans, arr[i]);
164164
}
165165
return ans;
166-
};
166+
}
167167
```
168168

169169
### **...**

solution/1800-1899/1846.Maximum Element After Decreasing and Rearranging/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function maximumElementAfterDecrementingAndRearranging(arr: number[]): number {
151151
ans = Math.max(ans, arr[i]);
152152
}
153153
return ans;
154-
};
154+
}
155155
```
156156

157157
### **...**

solution/1800-1899/1846.Maximum Element After Decreasing and Rearranging/Solution.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ function maximumElementAfterDecrementingAndRearranging(arr: number[]): number {
88
ans = Math.max(ans, arr[i]);
99
}
1010
return ans;
11-
};
11+
}

solution/2200-2299/2261.K Divisible Elements Subarrays/README_EN.md

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

55
## Description
66

7-
<p>Given an integer array <code>nums</code> and two integers <code>k</code> and <code>p</code>, return <em>the number of <strong>distinct subarrays</strong> which have <strong>at most</strong></em> <code>k</code> <em>elements divisible by</em> <code>p</code>.</p>
7+
<p>Given an integer array <code>nums</code> and two integers <code>k</code> and <code>p</code>, return <em>the number of <strong>distinct subarrays,</strong> which have <strong>at most</strong></em> <code>k</code> <em>elements </em>that are&nbsp;<em>&nbsp;divisible by</em> <code>p</code>.</p>
88

99
<p>Two arrays <code>nums1</code> and <code>nums2</code> are said to be <strong>distinct</strong> if:</p>
1010

solution/2500-2599/2561.Rearranging Fruits/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<p>You have two fruit baskets containing <code>n</code> fruits each. You are given two <strong>0-indexed</strong> integer arrays <code>basket1</code> and <code>basket2</code> representing the cost of fruit in each basket. You want to make both baskets <strong>equal</strong>. To do so, you can use the following operation as many times as you want:</p>
88

99
<ul>
10-
<li>Chose two indices <code>i</code> and <code>j</code>, and swap the <code>i<sup>th</sup> </code>fruit of <code>basket1</code> with the <code>j<sup>th</sup></code> fruit of <code>basket2</code>.</li>
10+
<li>Chose two indices <code>i</code> and <code>j</code>, and swap the <code>i<font size="1">th</font>&nbsp;</code>fruit of <code>basket1</code> with the <code>j<font size="1">th</font></code>&nbsp;fruit of <code>basket2</code>.</li>
1111
<li>The cost of the swap is <code>min(basket1[i],basket2[j])</code>.</li>
1212
</ul>
1313

solution/2700-2799/2705.Compact Object/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<p><strong>Constraints:</strong></p>
3737

3838
<ul>
39-
<li><code>obj is a valid JSON object</code></li>
39+
<li><code>obj</code> is a valid JSON object</li>
4040
<li><code>2 &lt;= JSON.stringify(obj).length &lt;= 10<sup>6</sup></code></li>
4141
</ul>
4242

solution/2700-2799/2710.Remove Trailing Zeros From a String/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838

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

41+
**方法一:遍历**
42+
43+
我们可以从后往前遍历字符串,遇到第一个不是 `0` 的字符时停止遍历,然后返回从头开始到这个字符的子串。
44+
45+
时间复杂度 $O(n)$,其中 $n$ 是字符串的长度。忽略答案字符串的空间消耗,空间复杂度 $O(1)$。
46+
4147
<!-- tabs:start -->
4248

4349
### **Python3**

0 commit comments

Comments
 (0)