Skip to content

Commit 5504b39

Browse files
authored
feat: update lc problems (#3634)
1 parent ccf55f2 commit 5504b39

File tree

29 files changed

+354
-336
lines changed

29 files changed

+354
-336
lines changed

solution/0200-0299/0297.Serialize and Deserialize Binary Tree/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tags:
2525

2626
<p>Design an algorithm to serialize and deserialize a binary tree. There is no restriction on how your serialization/deserialization algorithm should work. You just need to ensure that a binary tree can be serialized to a string and this string can be deserialized to the original tree structure.</p>
2727

28-
<p><strong>Clarification:</strong> The input/output format is the same as <a href="https://support.leetcode.com/hc/en-us/articles/360011883654-What-does-1-null-2-3-mean-in-binary-tree-representation-" target="_blank">how LeetCode serializes a binary tree</a>. You do not necessarily need to follow this format, so please be creative and come up with different approaches yourself.</p>
28+
<p><strong>Clarification:</strong> The input/output format is the same as <a href="https://support.leetcode.com/hc/en-us/articles/32442719377939-How-to-create-test-cases-on-LeetCode#h_01J5EGREAW3NAEJ14XC07GRW1A" target="_blank">how LeetCode serializes a binary tree</a>. You do not necessarily need to follow this format, so please be creative and come up with different approaches yourself.</p>
2929

3030
<p>&nbsp;</p>
3131
<p><strong class="example">Example 1:</strong></p>

solution/0500-0599/0593.Valid Square/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tags:
2929

3030
<pre>
3131
<strong>输入:</strong> p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0,1]
32-
<strong>输出:</strong> True
32+
<strong>输出:</strong> true
3333
</pre>
3434

3535
<p><strong>示例 2:</strong></p>

solution/0500-0599/0594.Longest Harmonious Subsequence/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tags:
2222

2323
<p>和谐数组是指一个数组里元素的最大值和最小值之间的差别 <strong>正好是 <code>1</code></strong> 。</p>
2424

25-
<p>给你一个整数数组 <code>nums</code> ,请你在所有可能的子序列中找到最长的和谐子序列的长度。</p>
25+
<p>给你一个整数数组 <code>nums</code> ,请你在所有可能的 <span data-keyword="subsequence-array">子序列</span> 中找到最长的和谐子序列的长度。</p>
2626

2727
<p>数组的 <strong>子序列</strong> 是一个由数组派生出来的序列,它可以通过删除一些元素或不删除元素、且不改变其余元素的顺序而得到。</p>
2828

solution/0500-0599/0594.Longest Harmonious Subsequence/README_EN.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ tags:
2222

2323
<p>We define a harmonious array as an array where the difference between its maximum value and its minimum value is <b>exactly</b> <code>1</code>.</p>
2424

25-
<p>Given an integer array <code>nums</code>, return <em>the length of its longest harmonious subsequence among all its possible subsequences</em>.</p>
26-
27-
<p>A <strong>subsequence</strong> of array is a sequence that can be derived from the array by deleting some or no elements without changing the order of the remaining elements.</p>
25+
<p>Given an integer array <code>nums</code>, return the length of its longest harmonious <span data-keyword="subsequence-array">subsequence</span> among all its possible subsequences.</p>
2826

2927
<p>&nbsp;</p>
3028
<p><strong class="example">Example 1:</strong></p>

solution/0900-0999/0975.Odd Even Jump/README.md

+16-13
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,29 @@ tags:
2020

2121
<!-- description:start -->
2222

23-
<p>给定一个整数数组 <code>A</code>,你可以从某一起始索引出发,跳跃一定次数。在你跳跃的过程中,第 1、3、5... 次跳跃称为奇数跳跃,而第 2、4、6... 次跳跃称为偶数跳跃。</p>
23+
<p>给定一个整数数组 <code>arr</code>,你可以从某一起始索引出发,跳跃一定次数。在你跳跃的过程中,第 1、3、5... 次跳跃称为奇数跳跃,而第 2、4、6... 次跳跃称为偶数跳跃。</p>
2424

2525
<p>你可以按以下方式从索引 <code>i</code>&nbsp;向后跳转到索引 <code>j</code>(其中 <code>i &lt; j</code>):</p>
2626

2727
<ul>
28-
<li>在进行奇数跳跃时(如,第&nbsp;1,3,5... 次跳跃),你将会跳到索引 <code>j</code>,使得 <code>A[i] &lt;=&nbsp;A[j]</code>,<code>A[j]</code> 是可能的最小值。如果存在多个这样的索引 <code>j</code>,你只能跳到满足要求的<strong>最小</strong>索引 <code>j</code> 上。</li>
29-
<li>在进行偶数跳跃时(如,第&nbsp;2,4,6... 次跳跃),你将会跳到索引&nbsp;<code>j</code>,使得 <code>A[i] &gt;= A[j]</code>,<code>A[j]</code> 是可能的最大值。如果存在多个这样的索引 <code>j</code>,你只能跳到满足要求的<strong>最小</strong>索引 <code>j</code>&nbsp;上。</li>
28+
<li>在进行奇数跳跃时(如,第&nbsp;1,3,5... 次跳跃),你将会跳到索引 <code>j</code>,使得 <code>arr[i] &lt;=&nbsp;arr[j]</code>,<code>arr[j]</code> 的值尽可能小。如果存在多个这样的索引 <code>j</code>,你只能跳到满足要求的<strong>最小</strong>索引 <code>j</code> 上。</li>
29+
<li>在进行偶数跳跃时(如,第&nbsp;2,4,6... 次跳跃),你将会跳到索引&nbsp;<code>j</code>,使得 <code>arr[i] &gt;= arr[j]</code>,<code>arr[j]</code> 的值尽可能大。如果存在多个这样的索引 <code>j</code>,你只能跳到满足要求的<strong>最小</strong>索引 <code>j</code>&nbsp;上。</li>
3030
<li>(对于某些索引 <code>i</code>,可能无法进行合乎要求的跳跃。)</li>
3131
</ul>
3232

33-
<p>如果从某一索引开始跳跃一定次数(可能是 0 次或多次),就可以到达数组的末尾(索引 <code>A.length - 1</code>),那么该索引就会被认为是好的起始索引。</p>
33+
<p>如果从某一索引开始跳跃一定次数(可能是 0 次或多次),就可以到达数组的末尾(索引 <code>arr.length - 1</code>),那么该索引就会被认为是好的起始索引。</p>
3434

3535
<p>返回好的起始索引的数量。</p>
3636

3737
<p>&nbsp;</p>
3838

3939
<p><strong>示例 1:</strong></p>
4040

41-
<pre><strong>输入:</strong>[10,13,12,14,15]
41+
<pre>
42+
<strong>输入:</strong>[10,13,12,14,15]
4243
<strong>输出:</strong>2
4344
<strong>解释: </strong>
44-
从起始索引 i = 0 出发,我们可以跳到 i = 2,(因为 A[2] 是 A[1],A[2],A[3],A[4] 中大于或等于 A[0] 的最小值),然后我们就无法继续跳下去了。
45+
从起始索引 i = 0 出发,我们可以跳到 i = 2,(因为 arr[2] 是 arr[1],arr[2],arr[3],arr[4] 中大于或等于 arr[0] 的最小值),然后我们就无法继续跳下去了。
4546
从起始索引 i = 1 和 i = 2 出发,我们可以跳到 i = 3,然后我们就无法继续跳下去了。
4647
从起始索引 i = 3 出发,我们可以跳到 i = 4,到达数组末尾。
4748
从起始索引 i = 4 出发,我们已经到达数组末尾。
@@ -50,16 +51,17 @@ tags:
5051

5152
<p><strong>示例&nbsp;2:</strong></p>
5253

53-
<pre><strong>输入:</strong>[2,3,1,1,4]
54+
<pre>
55+
<strong>输入:</strong>[2,3,1,1,4]
5456
<strong>输出:</strong>3
5557
<strong>解释:</strong>
5658
从起始索引 i=0 出发,我们依次可以跳到 i = 1,i = 2,i = 3:
5759

58-
在我们的第一次跳跃(奇数)中,我们先跳到 i = 1,因为 A[1] 是(A[1],A[2],A[3],A[4])中大于或等于 A[0] 的最小值。
60+
在我们的第一次跳跃(奇数)中,我们先跳到 i = 1,因为 arr[1] 是(arr[1],arr[2],arr[3],arr[4])中大于或等于 arr[0] 的最小值。
5961

60-
在我们的第二次跳跃(偶数)中,我们从 i = 1 跳到 i = 2,因为 A[2] 是(A[2],A[3],A[4])中小于或等于 A[1] 的最大值。A[3] 也是最大的值,但 2 是一个较小的索引,所以我们只能跳到 i = 2,而不能跳到 i = 3。
62+
在我们的第二次跳跃(偶数)中,我们从 i = 1 跳到 i = 2,因为 arr[2] 是(arr[2],arr[3],arr[4])中小于或等于 arr[1] 的最大值。arr[3] 也是最大的值,但 2 是一个较小的索引,所以我们只能跳到 i = 2,而不能跳到 i = 3。
6163

62-
在我们的第三次跳跃(奇数)中,我们从 i = 2 跳到 i = 3,因为 A[3] 是(A[3],A[4])中大于或等于 A[2] 的最小值。
64+
在我们的第三次跳跃(奇数)中,我们从 i = 2 跳到 i = 3,因为 arr[3] 是(arr[3],arr[4])中大于或等于 arr[2] 的最小值。
6365

6466
我们不能从 i = 3 跳到 i = 4,所以起始索引 i = 0 不是好的起始索引。
6567

@@ -73,7 +75,8 @@ tags:
7375

7476
<p><strong>示例 3:</strong></p>
7577

76-
<pre><strong>输入:</strong>[5,1,3,4,2]
78+
<pre>
79+
<strong>输入:</strong>[5,1,3,4,2]
7780
<strong>输出:</strong>3
7881
<strong>解释: </strong>
7982
我们可以从起始索引 1,2,4 出发到达数组末尾。
@@ -84,8 +87,8 @@ tags:
8487
<p><strong>提示:</strong></p>
8588

8689
<ol>
87-
<li><code>1 &lt;= A.length &lt;= 20000</code></li>
88-
<li><code>0 &lt;= A[i] &lt; 100000</code></li>
90+
<li><code>1 &lt;= arr.length &lt;= 20000</code></li>
91+
<li><code>0 &lt;= arr[i] &lt; 100000</code></li>
8992
</ol>
9093

9194
<!-- description:end -->

solution/1200-1299/1281.Subtract the Product and Sum of Digits of an Integer/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ tags:
2525
<p><strong>示例 1:</strong></p>
2626

2727
<pre><strong>输入:</strong>n = 234
28-
<strong>输出:</strong>15
28+
<strong>输出:</strong>15
2929
<strong>解释:</strong>
30-
各位数之积 = 2 * 3 * 4 = 24
31-
各位数之和 = 2 + 3 + 4 = 9
30+
各位数之积 = 2 * 3 * 4 = 24
31+
各位数之和 = 2 + 3 + 4 = 9
3232
结果 = 24 - 9 = 15
3333
</pre>
3434

3535
<p><strong>示例 2:</strong></p>
3636

3737
<pre><strong>输入:</strong>n = 4421
3838
<strong>输出:</strong>21
39-
<strong>解释:
40-
</strong>各位数之积 = 4 * 4 * 2 * 1 = 32
41-
各位数之和 = 4 + 4 + 2 + 1 = 11
39+
<strong>解释:
40+
</strong>各位数之积 = 4 * 4 * 2 * 1 = 32
41+
各位数之和 = 4 + 4 + 2 + 1 = 11
4242
结果 = 32 - 11 = 21
4343
</pre>
4444

solution/1200-1299/1281.Subtract the Product and Sum of Digits of an Integer/README_EN.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ Given an integer number <code>n</code>, return the difference between the produc
2525

2626
<pre>
2727
<strong>Input:</strong> n = 234
28-
<strong>Output:</strong> 15
29-
<b>Explanation:</b>
30-
Product of digits = 2 * 3 * 4 = 24
31-
Sum of digits = 2 + 3 + 4 = 9
28+
<strong>Output:</strong> 15
29+
<b>Explanation:</b>
30+
Product of digits = 2 * 3 * 4 = 24
31+
Sum of digits = 2 + 3 + 4 = 9
3232
Result = 24 - 9 = 15
3333
</pre>
3434

@@ -37,9 +37,9 @@ Result = 24 - 9 = 15
3737
<pre>
3838
<strong>Input:</strong> n = 4421
3939
<strong>Output:</strong> 21
40-
<b>Explanation:
41-
</b>Product of digits = 4 * 4 * 2 * 1 = 32
42-
Sum of digits = 4 + 4 + 2 + 1 = 11
40+
<b>Explanation:
41+
</b>Product of digits = 4 * 4 * 2 * 1 = 32
42+
Sum of digits = 4 + 4 + 2 + 1 = 11
4343
Result = 32 - 11 = 21
4444
</pre>
4545

solution/1200-1299/1295.Find Numbers with Even Number of Digits/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tags:
4141

4242
<pre>
4343
<strong>输入:</strong>nums = [555,901,482,1771]
44-
<strong>输出:</strong>1
44+
<strong>输出:</strong>1
4545
<strong>解释: </strong>
4646
只有 1771 是位数为偶数的数字。
4747
</pre>

solution/1200-1299/1295.Find Numbers with Even Number of Digits/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ tags:
2727
<pre>
2828
<strong>Input:</strong> nums = [12,345,2,6,7896]
2929
<strong>Output:</strong> 2
30-
<strong>Explanation:
30+
<strong>Explanation:
3131
</strong>12 contains 2 digits (even number of digits).&nbsp;
3232
345 contains 3 digits (odd number of digits).&nbsp;
3333
2 contains 1 digit (odd number of digits).&nbsp;
@@ -40,7 +40,7 @@ Therefore only 12 and 7896 contain an even number of digits.
4040

4141
<pre>
4242
<strong>Input:</strong> nums = [555,901,482,1771]
43-
<strong>Output:</strong> 1
43+
<strong>Output:</strong> 1
4444
<strong>Explanation: </strong>
4545
Only 1771 contains an even number of digits.
4646
</pre>

solution/1200-1299/1299.Replace Elements with Greatest Element on Right Side/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tags:
2828
<pre>
2929
<strong>Input:</strong> arr = [17,18,5,4,6,1]
3030
<strong>Output:</strong> [18,6,6,6,1,-1]
31-
<strong>Explanation:</strong>
31+
<strong>Explanation:</strong>
3232
- index 0 --&gt; the greatest element to the right of index 0 is index 1 (18).
3333
- index 1 --&gt; the greatest element to the right of index 1 is index 4 (6).
3434
- index 2 --&gt; the greatest element to the right of index 2 is index 4 (6).

solution/1400-1499/1470.Shuffle the Array/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ tags:
2727
<p><strong>示例 1:</strong></p>
2828

2929
<pre><strong>输入:</strong>nums = [2,5,1,3,4,7], n = 3
30-
<strong>输出:</strong>[2,3,5,4,1,7]
30+
<strong>输出:</strong>[2,3,5,4,1,7]
3131
<strong>解释:</strong>由于 x<sub>1</sub>=2, x<sub>2</sub>=5, x<sub>3</sub>=1, y<sub>1</sub>=3, y<sub>2</sub>=4, y<sub>3</sub>=7 ,所以答案为 [2,3,5,4,1,7]
3232
</pre>
3333

solution/1400-1499/1470.Shuffle the Array/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ tags:
3030

3131
<strong>Input:</strong> nums = [2,5,1,3,4,7], n = 3
3232

33-
<strong>Output:</strong> [2,3,5,4,1,7]
33+
<strong>Output:</strong> [2,3,5,4,1,7]
3434

3535
<strong>Explanation:</strong> Since x<sub>1</sub>=2, x<sub>2</sub>=5, x<sub>3</sub>=1, y<sub>1</sub>=3, y<sub>2</sub>=4, y<sub>3</sub>=7 then the answer is [2,3,5,4,1,7].
3636

solution/1400-1499/1473.Paint House III/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Cost of paint all houses (1 + 1 + 1 + 1 + 5) = 9.
5353
<strong>Input:</strong> houses = [0,2,1,2,0], cost = [[1,10],[10,1],[10,1],[1,10],[5,1]], m = 5, n = 2, target = 3
5454
<strong>Output:</strong> 11
5555
<strong>Explanation:</strong> Some houses are already painted, Paint the houses of this way [2,2,1,2,2]
56-
This array contains target = 3 neighborhoods, [{2,2}, {1}, {2,2}].
56+
This array contains target = 3 neighborhoods, [{2,2}, {1}, {2,2}].
5757
Cost of paint the first and last house (10 + 1) = 11.
5858
</pre>
5959

solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ tags:
3232
<pre>
3333
<strong>Input:</strong> prices = [8,4,6,2,3]
3434
<strong>Output:</strong> [4,2,4,2,3]
35-
<strong>Explanation:</strong>
35+
<strong>Explanation:</strong>
3636
For item 0 with price[0]=8 you will receive a discount equivalent to prices[1]=4, therefore, the final price you will pay is 8 - 4 = 4.
3737
For item 1 with price[1]=4 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 4 - 2 = 2.
3838
For item 2 with price[2]=6 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 6 - 2 = 4.

0 commit comments

Comments
 (0)