Skip to content

Commit aae0d64

Browse files
committed
feat: update lc problems
1 parent 863a34a commit aae0d64

File tree

64 files changed

+3324
-665
lines changed

Some content is hidden

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

64 files changed

+3324
-665
lines changed

solution/0200-0299/0258.Add Digits/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
由于&nbsp;<code>2</code> 是一位数,所以返回 2。
2222
</pre>
2323

24-
<p><strong>示例 1:</strong></p>
24+
<p><strong>示例 2:</strong></p>
2525

2626
<pre>
2727
<strong>输入:</strong> num =<strong> </strong>0

solution/2100-2199/2153.The Number of Passengers in Each Bus II/README.md

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# [2153. The Number of Passengers in Each Bus II](https://leetcode.cn/problems/the-number-of-passengers-in-each-bus-ii)
1+
# [2153. 每辆车的乘客人数 II](https://leetcode.cn/problems/the-number-of-passengers-in-each-bus-ii)
22

33
[English Version](/solution/2100-2199/2153.The%20Number%20of%20Passengers%20in%20Each%20Bus%20II/README_EN.md)
44

55
## 题目描述
66

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

9-
<p>Table: <code>Buses</code></p>
9+
<p>: <code>Buses</code></p>
1010

1111
<pre>
1212
+--------------+------+
@@ -16,14 +16,14 @@
1616
| arrival_time | int |
1717
| capacity | int |
1818
+--------------+------+
19-
bus_id is the primary key column for this table.
20-
Each row of this table contains information about the arrival time of a bus at the LeetCode station and its capacity (the number of empty seats it has).
21-
No two buses will arrive at the same time and all bus capacities will be positive integers.
19+
bus_id 是该表的主键。
20+
该表的每一行都包含关于公交车到达 LeetCode 站点的时间和它的容量 (空座位的数量) 的信息。
21+
不会出现两辆公交车同时到达,所有公交车的容量都是正整数。
2222
</pre>
2323

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

26-
<p>Table: <code>Passengers</code></p>
26+
<p>: <code>Passengers</code></p>
2727

2828
<pre>
2929
+--------------+------+
@@ -32,34 +32,35 @@ No two buses will arrive at the same time and all bus capacities will be positiv
3232
| passenger_id | int |
3333
| arrival_time | int |
3434
+--------------+------+
35-
passenger_id is the primary key column for this table.
36-
Each row of this table contains information about the arrival time of a passenger at the LeetCode station.
35+
passenger_id 是该表的主键。
36+
该表的每一行都包含乘客到达 LeetCode 站的时间信息。
3737
</pre>
3838

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

41-
<p>Buses and passengers arrive at the LeetCode station. If a bus arrives at the station at a time <code>t<sub>bus</sub></code> and a passenger arrived at a time <code>t<sub>passenger</sub></code> where <code>t<sub>passenger</sub> &lt;= t<sub>bus</sub></code> and the passenger did not catch any bus, the passenger will use that bus. In addition, each bus has a capacity. If at the moment the bus arrives at the station there are more passengers waiting than its capacity <code>capacity</code>, only <code>capacity</code> passengers will use the bus.</p>
41+
<p>公交车和乘客到达 LeetCode 站。如果一辆公交车在 <code>t<sub>bus</sub></code> 时间点到达车站,乘客在 <code>t<sub>passenger</sub></code> 到达车站,其中&nbsp;<code>t<sub>passenger</sub> &lt;= t<sub>bus</sub></code>,而该乘客没有赶上任何公交车,则该乘客将搭乘该公交车。此外,每辆公交车都有一个容量。如果在公交车到站的那一刻,等待的乘客超过了它的载客量 <code>capacity</code>,只有&nbsp;<code>capacity</code> 个乘客才会搭乘该公交车。</p>
4242

43-
<p>Write an SQL query to report the number of users that used each bus.</p>
43+
<p>编写一个 SQL 来查询使用每条总线的用户数量。</p>
4444

45-
<p>Return the result table ordered by <code>bus_id</code> in <strong>ascending order</strong>.</p>
45+
<p>返回按 <code>bus_id</code> <strong>升序排序&nbsp;</strong>的结果表。</p>
4646

47-
<p>The query result format is in the following example.</p>
47+
<p>查询结果格式如下所示。</p>
4848

4949
<p>&nbsp;</p>
50-
<p><strong class="example">Example 1:</strong></p>
50+
51+
<p><strong>示例 1:</strong></p>
5152

5253
<pre>
53-
<strong>Input:</strong>
54-
Buses table:
54+
<strong>输入:</strong>
55+
Buses :
5556
+--------+--------------+----------+
5657
| bus_id | arrival_time | capacity |
5758
+--------+--------------+----------+
5859
| 1 | 2 | 1 |
5960
| 2 | 4 | 10 |
6061
| 3 | 7 | 2 |
6162
+--------+--------------+----------+
62-
Passengers table:
63+
Passengers :
6364
+--------------+--------------+
6465
| passenger_id | arrival_time |
6566
+--------------+--------------+
@@ -69,26 +70,25 @@ Passengers table:
6970
| 14 | 6 |
7071
| 15 | 7 |
7172
+--------------+--------------+
72-
<strong>Output:</strong>
73+
<strong>输出:</strong>
7374
+--------+----------------+
7475
| bus_id | passengers_cnt |
7576
+--------+----------------+
7677
| 1 | 1 |
7778
| 2 | 1 |
7879
| 3 | 2 |
7980
+--------+----------------+
80-
<strong>Explanation:</strong>
81-
- Passenger 11 arrives at time 1.
82-
- Passenger 12 arrives at time 1.
83-
- Bus 1 arrives at time 2 and collects passenger 11 as it has one empty seat.
81+
<strong>解释:</strong>
82+
- 11 号乘客在时间 1 到达。
83+
- 12 号乘客在时间 1 到达。
84+
- 1 号公交车到达时间为 2,因为有一个空座位,所以搭载了 11 号乘客。
8485

85-
- Bus 2 arrives at time 4 and collects passenger 12 as it has ten empty seats.
86+
- 2 号公交车在时间 4 到达,搭载了12 号乘客,因为它有 10 个空座位。
8687

87-
- Passenger 12 arrives at time 5.
88-
- Passenger 13 arrives at time 6.
89-
- Passenger 14 arrives at time 7.
90-
- Bus 3 arrives at time 7 and collects passengers 12 and 13 as it has two empty seats.
91-
</pre>
88+
- 13 号乘客在时间 5 到达。
89+
- 14 号乘客在时间 6 到达。
90+
- 15 号乘客在时间 7 到达。
91+
- 3 号公交车在时间 7 到达,车上有两个空座位,搭载了 12 号和 13 号乘客。</pre>
9292

9393
## 解法
9494

solution/2100-2199/2174.Remove All Ones With Row and Column Flips II/README.md

+27-26
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,66 @@
1-
# [2174. Remove All Ones With Row and Column Flips II](https://leetcode.cn/problems/remove-all-ones-with-row-and-column-flips-ii)
1+
# [2174. 通过翻转行或列来去除所有的 1 II](https://leetcode.cn/problems/remove-all-ones-with-row-and-column-flips-ii)
22

33
[English Version](/solution/2100-2199/2174.Remove%20All%20Ones%20With%20Row%20and%20Column%20Flips%20II/README_EN.md)
44

55
## 题目描述
66

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

9-
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> <strong>binary</strong> matrix <code>grid</code>.</p>
9+
<p>给定&nbsp;<strong>下标从 0 开始&nbsp;</strong> <code>m x n</code> <strong>二进制&nbsp;</strong>矩阵 <code>grid</code></p>
1010

11-
<p>In one operation, you can choose any <code>i</code> and <code>j</code> that meet the following conditions:</p>
11+
<p>在一次操作中,可以选择满足以下条件的任意 <code>i</code> <code>j</code>:</p>
1212

1313
<ul>
1414
<li><code>0 &lt;= i &lt; m</code></li>
1515
<li><code>0 &lt;= j &lt; n</code></li>
1616
<li><code>grid[i][j] == 1</code></li>
1717
</ul>
1818

19-
<p>and change the values of <strong>all</strong> cells in row <code>i</code> and column <code>j</code> to zero.</p>
19+
<p>并将第 <code>i</code> 行和第 <code>j</code> 列中的&nbsp;<strong>所有&nbsp;</strong>单元格的值更改为零。</p>
2020

21-
<p>Return <em>the <strong>minimum</strong> number of operations needed to remove all </em><code>1</code><em>&#39;s from </em><code>grid</code><em>.</em></p>
21+
<p>返回<em>&nbsp;</em><code>grid</code><em> 中删除所有 <code>1</code> 所需的最小操作数。</em></p>
2222

2323
<p>&nbsp;</p>
24-
<p><strong class="example">Example 1:</strong></p>
24+
25+
<p><strong class="example">示例 1:</strong></p>
2526
<img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2100-2199/2174.Remove%20All%20Ones%20With%20Row%20and%20Column%20Flips%20II/images/image-20220213162716-1.png" style="width: 709px; height: 200px;" />
2627
<pre>
27-
<strong>Input:</strong> grid = [[1,1,1],[1,1,1],[0,1,0]]
28-
<strong>Output:</strong> 2
29-
<strong>Explanation:</strong>
30-
In the first operation, change all cell values of row 1 and column 1 to zero.
31-
In the second operation, change all cell values of row 0 and column 0 to zero.
28+
<strong>输入:</strong> grid = [[1,1,1],[1,1,1],[0,1,0]]
29+
<strong>输出:</strong> 2
30+
<strong>解释:</strong>
31+
在第一个操作中,将第 1 行和第 1 列的所有单元格值更改为 0。
32+
在第二个操作中,将第 0 行和第 0 列的所有单元格值更改为 0。
3233
</pre>
3334

34-
<p><strong class="example">Example 2:</strong></p>
35+
<p><strong class="example">示例 2:</strong></p>
3536
<img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2100-2199/2174.Remove%20All%20Ones%20With%20Row%20and%20Column%20Flips%20II/images/image-20220213162737-2.png" style="width: 734px; height: 200px;" />
3637
<pre>
37-
<strong>Input:</strong> grid = [[0,1,0],[1,0,1],[0,1,0]]
38-
<strong>Output:</strong> 2
39-
<strong>Explanation:</strong>
40-
In the first operation, change all cell values of row 1 and column 0 to zero.
41-
In the second operation, change all cell values of row 2 and column 1 to zero.
42-
Note that we cannot perform an operation using row 1 and column 1 because grid[1][1] != 1.
38+
<strong>输入:</strong> grid = [[0,1,0],[1,0,1],[0,1,0]]
39+
<strong>输出:</strong> 2
40+
<strong>解释:</strong>
41+
在第一个操作中,将第 1 行和第 0 列的所有单元格值更改为 0。
42+
在第二个操作中,将第 2 行和第 1 列的所有单元格值更改为 0。
43+
注意,我们不能使用行 1 和列 1 执行操作,因为 grid[1][1]!= 1
4344
</pre>
4445

45-
<p><strong class="example">Example 3:</strong></p>
46+
<p><strong class="example">示例 3:</strong></p>
4647
<img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2100-2199/2174.Remove%20All%20Ones%20With%20Row%20and%20Column%20Flips%20II/images/image-20220213162752-3.png" style="width: 156px; height: 150px;" />
4748
<pre>
48-
<strong>Input:</strong> grid = [[0,0],[0,0]]
49-
<strong>Output:</strong> 0
50-
<strong>Explanation:</strong>
51-
There are no 1&#39;s to remove so return 0.
52-
</pre>
49+
<strong>输入:</strong> grid = [[0,0],[0,0]]
50+
<strong>输出:</strong> 0
51+
<strong>解释:</strong>
52+
没有 1 可以移除,所以返回0。</pre>
5353

5454
<p>&nbsp;</p>
55-
<p><strong>Constraints:</strong></p>
55+
56+
<p><strong>提示:</strong></p>
5657

5758
<ul>
5859
<li><code>m == grid.length</code></li>
5960
<li><code>n == grid[i].length</code></li>
6061
<li><code>1 &lt;= m, n &lt;= 15</code></li>
6162
<li><code>1 &lt;= m * n &lt;= 15</code></li>
62-
<li><code>grid[i][j]</code> is either <code>0</code> or <code>1</code>.</li>
63+
<li><code>grid[i][j]</code> 为&nbsp;<code>0</code>&nbsp;或&nbsp;<code>1</code></li>
6364
</ul>
6465

6566
## 解法

solution/2100-2199/2199.Finding the Topic of Each Post/README.md

+36-39
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# [2199. Finding the Topic of Each Post](https://leetcode.cn/problems/finding-the-topic-of-each-post)
1+
# [2199. 找到每篇文章的主题](https://leetcode.cn/problems/finding-the-topic-of-each-post)
22

33
[English Version](/solution/2100-2199/2199.Finding%20the%20Topic%20of%20Each%20Post/README_EN.md)
44

55
## 题目描述
66

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

9-
<p>Table: <code>Keywords</code></p>
9+
<p>: <code>Keywords</code></p>
1010

1111
<pre>
1212
+-------------+---------+
@@ -15,14 +15,14 @@
1515
| topic_id | int |
1616
| word | varchar |
1717
+-------------+---------+
18-
(topic_id, word) is the primary key for this table.
19-
Each row of this table contains the id of a topic and a word that is used to express this topic.
20-
There may be more than one word to express the same topic and one word may be used to express multiple topics.
18+
(topic_id, word) 是该表的主键。
19+
该表的每一行都包含一个主题的 id 和一个用于表达该主题的词。
20+
可以用多个词来表达同一个主题,也可以用一个词来表达多个主题。
2121
</pre>
2222

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

25-
<p>Table: <code>Posts</code></p>
25+
<p>: <code>Posts</code></p>
2626

2727
<pre>
2828
+-------------+---------+
@@ -31,32 +31,31 @@ There may be more than one word to express the same topic and one word may be us
3131
| post_id | int |
3232
| content | varchar |
3333
+-------------+---------+
34-
post_id is the primary key for this table.
35-
Each row of this table contains the ID of a post and its content.
36-
Content will consist only of English letters and spaces.
34+
post_id 是该表的主键。
35+
该表的每一行都包含一个帖子的 ID 及其内容。
36+
内容仅由英文字母和空格组成。
3737
</pre>
3838

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

41-
<p>Leetcode has collected some posts from its social media website and is interested in finding the topics of each post. Each topic can be expressed by one or more keywords. If a keyword of a certain topic exists in the content of a post (<strong>case insensitive</strong>) then the post has this topic.</p>
41+
<p>Leetcode 从其社交媒体网站上收集了一些帖子,并对每个帖子的主题感兴趣。每个主题可以由一个或多个关键字表示。如果某个主题的关键字存在于一个帖子的内容中 (不区分大小写),那么这个帖子就有这个主题。</p>
4242

43-
<p>Write an SQL query to find the topics of each post according to the following rules:</p>
43+
<p>编写一个 SQL 查询,根据以下规则查找每篇文章的主题:</p>
4444

4545
<ul>
46-
<li>If the post does not have keywords from any topic, its topic should be <code>&quot;Ambiguous!&quot;</code>.</li>
47-
<li>If the post has at least one keyword of any topic, its topic should be a string of the IDs of its topics sorted in ascending order and separated by commas <code>&#39;,&#39;</code>. The string should not contain duplicate IDs.</li>
46+
<li>如果帖子没有来自任何主题的关键词,那么它的主题应该是&nbsp;<code>"Ambiguous!"</code></li>
47+
<li>如果该帖子至少有一个主题的关键字,其主题应该是其主题的 id 按升序排列并以逗号 ',' 分隔的字符串。字符串不应该包含重复的 id。</li>
4848
</ul>
4949

50-
<p>Return the result table in <strong>any order</strong>.</p>
50+
<p>&nbsp;<strong>任意顺序&nbsp;</strong>返回结果表。</p>
5151

52-
<p>The query result format is in the following example.</p>
52+
<p>查询结果格式如下所示。</p>
5353

54-
<p>&nbsp;</p>
55-
<p><strong class="example">Example 1:</strong></p>
54+
<p><strong>示例 1:</strong></p>
5655

5756
<pre>
58-
<strong>Input:</strong>
59-
Keywords table:
57+
<strong>输入:</strong>
58+
Keywords :
6059
+----------+----------+
6160
| topic_id | word |
6261
+----------+----------+
@@ -65,7 +64,7 @@ Keywords table:
6564
| 3 | WAR |
6665
| 2 | Vaccine |
6766
+----------+----------+
68-
Posts table:
67+
Posts :
6968
+---------+------------------------------------------------------------------------+
7069
| post_id | content |
7170
+---------+------------------------------------------------------------------------+
@@ -74,7 +73,7 @@ Posts table:
7473
| 3 | stop the war and play handball |
7574
| 4 | warning I planted some flowers this morning and then got vaccinated |
7675
+---------+------------------------------------------------------------------------+
77-
<strong>Output:</strong>
76+
<strong>输出:</strong>
7877
+---------+------------+
7978
| post_id | topic |
8079
+---------+------------+
@@ -83,24 +82,22 @@ Posts table:
8382
| 3 | 1,3 |
8483
| 4 | Ambiguous! |
8584
+---------+------------+
86-
<strong>Explanation:</strong>
87-
1: &quot;We call it soccer They call it football hahaha&quot;
88-
&quot;football&quot; expresses topic 1. There is no other word that expresses any other topic.
89-
90-
2: &quot;Americans prefer basketball while Europeans love handball and football&quot;
91-
&quot;handball&quot; expresses topic 1. &quot;football&quot; expresses topic 1.
92-
There is no other word that expresses any other topic.
93-
94-
3: &quot;stop the war and play handball&quot;
95-
&quot;war&quot; expresses topic 3. &quot;handball&quot; expresses topic 1.
96-
There is no other word that expresses any other topic.
97-
98-
4: &quot;warning I planted some flowers this morning and then got vaccinated&quot;
99-
There is no word in this sentence that expresses any topic. Note that &quot;warning&quot; is different from &quot;war&quot; although they have a common prefix.
100-
This post is ambiguous.
101-
102-
Note that it is okay to have one word that expresses more than one topic.
103-
</pre>
85+
<strong>解释:</strong>
86+
1: "We call it soccer They call it football hahaha"
87+
"football" 表示主题 1。没有其他词能表示任何其他主题。
88+
89+
2: "Americans prefer basketball while Europeans love handball and football"
90+
"handball" 表示主题 1。"football" 表示主题 1。
91+
没有其他词能表示任何其他主题。
92+
93+
3: "stop the war and play handball"
94+
"war" 表示主题 3。 "handball" 表示主题 1。
95+
没有其他词能表示任何其他主题。
96+
97+
4: "warning I planted some flowers this morning and then got vaccinated"
98+
这个句子里没有一个词能表示任何主题。注意 “warning” 和 “war” 不同,尽管它们有一个共同的前缀。
99+
所以这篇文章 “Ambiguous!”
100+
请注意,可以使用一个词来表达多个主题。</pre>
104101

105102
## 解法
106103

0 commit comments

Comments
 (0)