Skip to content

Commit e53f9e7

Browse files
authored
feat: update lc problems (doocs#2280)
1 parent 91b3f1d commit e53f9e7

File tree

16 files changed

+135
-133
lines changed

16 files changed

+135
-133
lines changed

solution/0100-0199/0197.Rising Temperature/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
| temperature | int |
2020
+---------------+---------+
2121
id 是该表具有唯一值的列。
22+
没有具有相同 recordDate 的不同行。
2223
该表包含特定日期的温度信息</pre>
2324

2425
<p>&nbsp;</p>

solution/0100-0199/0197.Rising Temperature/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
| temperature | int |
1616
+---------------+---------+
1717
id is the column with unique values for this table.
18+
There are no different rows with the same recordDate.
1819
This table contains information about the temperature on a certain day.
1920
</pre>
2021

solution/0500-0599/0521.Longest Uncommon Subsequence I/README_EN.md

+3-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44

55
## Description
66

7-
<p>Given two strings <code>a</code> and <code>b</code>, return <em>the length of the <strong>longest uncommon subsequence</strong> between </em><code>a</code> <em>and</em> <code>b</code>. If the longest uncommon subsequence does not exist, return <code>-1</code>.</p>
7+
<p>Given two strings <code>a</code> and <code>b</code>, return <em>the length of the <strong>longest uncommon subsequence</strong> between </em><code>a</code> <em>and</em> <code>b</code>. <em>If no such uncommon subsequence exists, return</em> <code>-1</code><em>.</em></p>
88

9-
<p>An <strong>uncommon subsequence</strong> between two strings is a string that is a <strong>subsequence of one but not the other</strong>.</p>
10-
11-
<p>A <strong>subsequence</strong> of a string <code>s</code> is a string that can be obtained after deleting any number of characters from <code>s</code>.</p>
12-
13-
<ul>
14-
<li>For example, <code>&quot;abc&quot;</code> is a subsequence of <code>&quot;aebdc&quot;</code> because you can delete the underlined characters in <code>&quot;a<u>e</u>b<u>d</u>c&quot;</code> to get <code>&quot;abc&quot;</code>. Other subsequences of <code>&quot;aebdc&quot;</code> include <code>&quot;aebdc&quot;</code>, <code>&quot;aeb&quot;</code>, and <code>&quot;&quot;</code> (empty string).</li>
15-
</ul>
9+
<p>An <strong>uncommon subsequence</strong> between two strings is a string that is a <strong><span data-keyword="subsequence-string">subsequence</span> of exactly one of them</strong>.</p>
1610

1711
<p>&nbsp;</p>
1812
<p><strong class="example">Example 1:</strong></p>
@@ -37,7 +31,7 @@ Note that &quot;cdc&quot; is also a longest uncommon subsequence.
3731
<pre>
3832
<strong>Input:</strong> a = &quot;aaa&quot;, b = &quot;aaa&quot;
3933
<strong>Output:</strong> -1
40-
<strong>Explanation:</strong>&nbsp;Every subsequence of string a is also a subsequence of string b. Similarly, every subsequence of string b is also a subsequence of string a.
34+
<strong>Explanation:</strong>&nbsp;Every subsequence of string a is also a subsequence of string b. Similarly, every subsequence of string b is also a subsequence of string a. So the answer would be <code>-1</code>.
4135
</pre>
4236

4337
<p>&nbsp;</p>

solution/0600-0699/0606.Construct String from Binary Tree/README_EN.md

+24-6
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,43 @@
44

55
## Description
66

7-
<p>Given the <code>root</code> of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it.</p>
7+
<p>Given the <code>root</code> node of a binary tree, your task is to create a string representation of the tree following a specific set of formatting rules. The representation should be based on a preorder traversal of the binary tree and must adhere to the following guidelines:</p>
88

9-
<p>Omit all the empty parenthesis pairs that do not affect the one-to-one mapping relationship between the string and the original binary tree.</p>
9+
<ul>
10+
<li>
11+
<p><strong>Node Representation</strong>: Each node in the tree should be represented by its integer value.</p>
12+
</li>
13+
<li>
14+
<p><strong>Parentheses for Children</strong>: If a node has at least one child (either left or right), its children should be represented inside parentheses. Specifically:</p>
15+
16+
<ul>
17+
<li>If a node has a left child, the value of the left child should be enclosed in parentheses immediately following the node&#39;s value.</li>
18+
<li>If a node has a right child, the value of the right child should also be enclosed in parentheses. The parentheses for the right child should follow those of the left child.</li>
19+
</ul>
20+
</li>
21+
<li>
22+
<p><strong>Omitting Empty Parentheses</strong>: Any empty parentheses pairs (i.e., <code>()</code>) should be omitted from the final string representation of the tree, with one specific exception: when a node has a right child but no left child. In such cases, you must include an empty pair of parentheses to indicate the absence of the left child. This ensures that the one-to-one mapping between the string representation and the original binary tree structure is maintained.</p>
23+
24+
<p>In summary, empty parentheses pairs should be omitted when a node has only a left child or no children. However, when a node has a right child but no left child, an empty pair of parentheses must precede the representation of the right child to reflect the tree&#39;s structure accurately.</p>
25+
</li>
26+
27+
</ul>
1028

1129
<p>&nbsp;</p>
1230
<p><strong class="example">Example 1:</strong></p>
13-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0600-0699/0606.Construct%20String%20from%20Binary%20Tree/images/cons1-tree.jpg" style="width: 292px; height: 301px;" />
31+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0600-0699/0606.Construct%20String%20from%20Binary%20Tree/images/cons1-tree.jpg" style="padding: 10px; background: #fff; border-radius: .5rem;" />
1432
<pre>
1533
<strong>Input:</strong> root = [1,2,3,4]
1634
<strong>Output:</strong> &quot;1(2(4))(3)&quot;
17-
<strong>Explanation:</strong> Originally, it needs to be &quot;1(2(4)())(3()())&quot;, but you need to omit all the unnecessary empty parenthesis pairs. And it will be &quot;1(2(4))(3)&quot;
35+
<strong>Explanation:</strong> Originally, it needs to be &quot;1(2(4)())(3()())&quot;, but you need to omit all the empty parenthesis pairs. And it will be &quot;1(2(4))(3)&quot;.
1836
</pre>
1937

2038
<p><strong class="example">Example 2:</strong></p>
21-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0600-0699/0606.Construct%20String%20from%20Binary%20Tree/images/cons2-tree.jpg" style="width: 207px; height: 293px;" />
39+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0600-0699/0606.Construct%20String%20from%20Binary%20Tree/images/cons2-tree.jpg" style="padding: 10px; background: #fff; border-radius: .5rem;" />
2240
<pre>
2341
<strong>Input:</strong> root = [1,2,3,null,4]
2442
<strong>Output:</strong> &quot;1(2()(4))(3)&quot;
25-
<strong>Explanation:</strong> Almost the same as the first example, except we cannot omit the first parenthesis pair to break the one-to-one mapping relationship between the input and the output.
43+
<strong>Explanation:</strong> Almost the same as the first example, except the <code>()</code> after <code>2</code> is necessary to indicate the absence of a left child for <code>2</code> and the presence of a right child.
2644
</pre>
2745

2846
<p>&nbsp;</p>

solution/0800-0899/0827.Making A Large Island/README.md

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

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

9-
<p>给你一个大小为 <code>n x n</code> 二进制矩阵 <code>grid</code> 。<strong>最多</strong> 只能将一格 <code>0</code> 变成 <code>1</code> 。</p>
9+
<p>给你一个大小为 <code>n x n</code> 二进制矩阵 <code>grid</code> 。<strong>最多</strong> 只能将一格&nbsp;<code>0</code> 变成&nbsp;<code>1</code> 。</p>
1010

1111
<p>返回执行此操作后,<code>grid</code> 中最大的岛屿面积是多少?</p>
1212

13-
<p><strong>岛屿</strong> 由一组上、下、左、右四个方向相连的 <code>1</code> 形成。</p>
13+
<p><strong>岛屿</strong> 由一组上、下、左、右四个方向相连的&nbsp;<code>1</code> 形成。</p>
1414

15-
<p> </p>
15+
<p>&nbsp;</p>
1616

17-
<p><strong>示例 1:</strong></p>
17+
<p><strong class="example">示例 1:</strong></p>
1818

1919
<pre>
2020
<strong>输入: </strong>grid = [[1, 0], [0, 1]]
2121
<strong>输出:</strong> 3
2222
<strong>解释:</strong> 将一格0变成1,最终连通两个小岛得到面积为 3 的岛屿。
2323
</pre>
2424

25-
<p><strong>示例 2:</strong></p>
25+
<p><strong class="example">示例 2:</strong></p>
2626

2727
<pre>
2828
<strong>输入: </strong>grid =<strong> </strong>[[1, 1], [1, 0]]
2929
<strong>输出:</strong> 4
3030
<strong>解释:</strong> 将一格0变成1,岛屿的面积扩大为 4。</pre>
3131

32-
<p><strong>示例 3:</strong></p>
32+
<p><strong class="example">示例 3:</strong></p>
3333

3434
<pre>
3535
<strong>输入: </strong>grid = [[1, 1], [1, 1]]
3636
<strong>输出:</strong> 4
3737
<strong>解释:</strong> 没有0可以让我们变成1,面积依然为 4。</pre>
3838

39-
<p> </p>
39+
<p>&nbsp;</p>
4040

4141
<p><strong>提示:</strong></p>
4242

4343
<ul>
4444
<li><code>n == grid.length</code></li>
4545
<li><code>n == grid[i].length</code></li>
46-
<li><code>1 <= n <= 500</code></li>
46+
<li><code>1 &lt;= n &lt;= 500</code></li>
4747
<li><code>grid[i][j]</code> 为 <code>0</code> 或 <code>1</code></li>
4848
</ul>
4949

solution/1600-1699/1657.Determine if Two Strings Are Close/README.md

+9-18
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
<li>操作 1:交换任意两个 <strong>现有</strong> 字符。
1313

1414
<ul>
15-
<li>例如,<code>a<strong>b</strong>cd<strong>e</strong> -> a<strong>e</strong>cd<strong>b</strong></code></li>
15+
<li>例如,<code>a<u>b</u>cd<u>e</u> -&gt; a<u>e</u>cd<u>b</u></code></li>
1616
</ul>
1717
</li>
1818
<li>操作 2:将一个 <strong>现有</strong> 字符的每次出现转换为另一个 <strong>现有</strong> 字符,并对另一个字符执行相同的操作。
1919
<ul>
20-
<li>例如,<code><strong>aa</strong>c<strong>abb</strong> -> <strong>bb</strong>c<strong>baa</strong></code>(所有 <code>a</code> 转化为 <code>b</code> ,而所有的 <code>b</code> 转换为 <code>a</code> )</li>
20+
<li>例如,<code><u>aa</u>c<u>abb</u> -&gt; <u>bb</u>c<u>baa</u></code>(所有 <code>a</code> 转化为 <code>b</code> ,而所有的 <code>b</code> 转换为 <code>a</code> )</li>
2121
</ul>
2222
</li>
2323

@@ -27,16 +27,16 @@
2727

2828
<p>给你两个字符串,<code>word1</code> 和 <code>word2</code> 。如果<em> </em><code>word1</code><em> </em>和<em> </em><code>word2</code><em> </em><strong>接近 </strong>,就返回 <code>true</code> ;否则,返回<em> </em><code>false</code><em> </em>。</p>
2929

30-
<p> </p>
30+
<p>&nbsp;</p>
3131

3232
<p><strong>示例 1:</strong></p>
3333

3434
<pre>
3535
<strong>输入:</strong>word1 = "abc", word2 = "bca"
3636
<strong>输出:</strong>true
3737
<strong>解释:</strong>2 次操作从 word1 获得 word2 。
38-
执行操作 1:"a<strong>bc</strong>" -> "a<strong>cb</strong>"
39-
执行操作 1:"<strong>a</strong>c<strong>b</strong>" -> "<strong>b</strong>c<strong>a</strong>"
38+
执行操作 1:"a<u>bc</u>" -&gt; "a<u>cb</u>"
39+
执行操作 1:"<u>a</u>c<u>b</u>" -&gt; "<u>b</u>c<u>a</u>"
4040
</pre>
4141

4242
<p><strong>示例 2:</strong></p>
@@ -52,24 +52,15 @@
5252
<strong>输入:</strong>word1 = "cabbba", word2 = "abbccc"
5353
<strong>输出:</strong>true
5454
<strong>解释:</strong>3 次操作从 word1 获得 word2 。
55-
执行操作 1:"ca<strong>b</strong>bb<strong>a</strong>" -> "ca<strong>a</strong>bb<strong>b</strong>"
56-
执行操作 2:<code>"</code><strong>c</strong>aa<strong>bbb</strong>" -> "<strong>b</strong>aa<strong>ccc</strong>"
57-
执行操作 2:"<strong>baa</strong>ccc" -> "<strong>abb</strong>ccc"
55+
执行操作 1:"ca<u>b</u>bb<u>a</u>" -&gt; "ca<u>a</u>bb<u>b</u>"
56+
执行操作 2:<code>"</code><u>c</u>aa<u>bbb</u>" -&gt; "<u>b</u>aa<u>ccc</u>"
57+
执行操作 2:"<u>baa</u>ccc" -&gt; "<u>abb</u>ccc"
5858
</pre>
5959

60-
<p><strong>示例 4:</strong></p>
61-
62-
<pre>
63-
<strong>输入:</strong>word1 = "cabbba", word2 = "aabbss"
64-
<strong>输出:</strong>false
65-
<strong>解释:</strong>不管执行多少次操作,都无法从 word1 得到 word2 ,反之亦然。</pre>
66-
67-
<p> </p>
68-
6960
<p><strong>提示:</strong></p>
7061

7162
<ul>
72-
<li><code>1 <= word1.length, word2.length <= 10<sup>5</sup></code></li>
63+
<li><code>1 &lt;= word1.length, word2.length &lt;= 10<sup>5</sup></code></li>
7364
<li><code>word1</code> 和 <code>word2</code> 仅包含小写英文字母</li>
7465
</ul>
7566

solution/1600-1699/1657.Determine if Two Strings Are Close/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Apply Operation 1: &quot;<u>a</u>c<u>b</u>&quot; -&gt; &quot;<u>b</u>c<u>a</u>&q
5151
<strong>Output:</strong> true
5252
<strong>Explanation:</strong> You can attain word2 from word1 in 3 operations.
5353
Apply Operation 1: &quot;ca<u>b</u>bb<u>a</u>&quot; -&gt; &quot;ca<u>a</u>bb<u>b</u>&quot;
54-
<code>Apply Operation 2: &quot;</code><u>c</u>aa<u>bbb</u>&quot; -&gt; &quot;<u>b</u>aa<u>ccc</u>&quot;
54+
Apply Operation 2: &quot;<u>c</u>aa<u>bbb</u>&quot; -&gt; &quot;<u>b</u>aa<u>ccc</u>&quot;
5555
Apply Operation 2: &quot;<u>baa</u>ccc&quot; -&gt; &quot;<u>abb</u>ccc&quot;
5656
</pre>
5757

solution/2100-2199/2186.Minimum Number of Steps to Make Two Strings Anagram II/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [2186. 使两字符串互为字母异位词的最少步骤数](https://leetcode.cn/problems/minimum-number-of-steps-to-make-two-strings-anagram-ii)
1+
# [2186. 制造字母异位词的最小步骤数 II](https://leetcode.cn/problems/minimum-number-of-steps-to-make-two-strings-anagram-ii)
22

33
[English Version](/solution/2100-2199/2186.Minimum%20Number%20of%20Steps%20to%20Make%20Two%20Strings%20Anagram%20II/README_EN.md)
44

solution/2200-2299/2254.Design Video Sharing Platform/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ videoSharingPlatform.remove(0); // Remove the video associated with
4040
videoSharingPlatform.upload(&quot;789&quot;); // Since the video associated with videoId 0 was deleted,
4141
// 0 is the smallest available <code>videoId</code>, so return 0.
4242
videoSharingPlatform.watch(1, 0, 5); // The video associated with videoId 1 is &quot;456&quot;.
43-
// The video from minute 0 to min(5, 3 - 1) = 2 is &quot;456&quot;, so return &quot;453&quot;.
43+
// The video from minute 0 to min(5, 3 - 1) = 2 is &quot;456&quot;, so return &quot;456&quot;.
4444
videoSharingPlatform.watch(1, 0, 1); // The video associated with videoId 1 is &quot;456&quot;.
4545
// The video from minute 0 to min(1, 3 - 1) = 1 is &quot;45&quot;, so return &quot;45&quot;.
4646
videoSharingPlatform.like(1); // Increase the number of likes on the video associated with videoId 1.

solution/2600-2699/2654.Minimum Number of Operations to Make All Array Elements Equal to 1/README_EN.md

-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@
4343
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
4444
</ul>
4545

46-
<p>&nbsp;</p>
47-
<p><b>Follow-up:</b></p>
48-
49-
<p>The <code>O(n)</code> time complexity&nbsp;solution works, but could you find an <code>O(1)</code> constant time complexity solution?</p>
50-
5146
## Solutions
5247

5348
### Solution 1

solution/2900-2999/2990.Loan Types/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ loan_id 是这张表具有唯一值的列。
3232

3333
<pre>
3434
<b>输入:</b>
35-
Sessions table:
35+
Loans table:
3636
+---------+---------+-----------+
3737
| loan_id | user_id | loan_type |
3838
+---------+---------+-----------+

solution/2900-2999/2990.Loan Types/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This table contains loan_id, user_id, and loan_type.
2929

3030
<pre>
3131
<strong>Input:</strong>
32-
Sessions table:
32+
Loans table:
3333
+---------+---------+-----------+
3434
| loan_id | user_id | loan_type |
3535
+---------+---------+-----------+

0 commit comments

Comments
 (0)