Skip to content

Commit 8b09d75

Browse files
authored
feat: update lc problems (#3947)
1 parent 636aad9 commit 8b09d75

File tree

80 files changed

+451
-207
lines changed

Some content is hidden

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

80 files changed

+451
-207
lines changed

solution/0000-0099/0014.Longest Common Prefix/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ tags:
4444
<ul>
4545
<li><code>1 &lt;= strs.length &lt;= 200</code></li>
4646
<li><code>0 &lt;= strs[i].length &lt;= 200</code></li>
47-
<li><code>strs[i]</code> 仅由小写英文字母组成</li>
47+
<li><code>strs[i]</code>&nbsp;如果非空,则仅由小写英文字母组成</li>
4848
</ul>
4949

5050
<!-- description:end -->

solution/0000-0099/0014.Longest Common Prefix/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ tags:
4343
<ul>
4444
<li><code>1 &lt;= strs.length &lt;= 200</code></li>
4545
<li><code>0 &lt;= strs[i].length &lt;= 200</code></li>
46-
<li><code>strs[i]</code> consists of only lowercase English letters.</li>
46+
<li><code>strs[i]</code> consists of only lowercase English letters if it is non-empty.</li>
4747
</ul>
4848

4949
<!-- description:end -->

solution/0000-0099/0045.Jump Game II/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ tags:
2020

2121
<p>给定一个长度为 <code>n</code> 的 <strong>0 索引</strong>整数数组 <code>nums</code>。初始位置为 <code>nums[0]</code>。</p>
2222

23-
<p>每个元素 <code>nums[i]</code> 表示从索引 <code>i</code> 向前跳转的最大长度。换句话说,如果你在 <code>nums[i]</code> 处,你可以跳转到任意 <code>nums[i + j]</code> 处:</p>
23+
<p>每个元素 <code>nums[i]</code> 表示从索引 <code>i</code> 向后跳转的最大长度。换句话说,如果你在 <code>nums[i]</code> 处,你可以跳转到任意 <code>nums[i + j]</code> 处:</p>
2424

2525
<ul>
2626
<li><code>0 &lt;= j &lt;= nums[i]</code>&nbsp;</li>

solution/0100-0199/0136.Single Number/README.md

+15-12
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,27 @@ tags:
2727

2828
<p><strong class="example">示例 1 :</strong></p>
2929

30-
<pre>
31-
<strong>输入:</strong>nums = [2,2,1]
32-
<strong>输出:</strong>1
33-
</pre>
30+
<div class="example-block">
31+
<p><strong>输入:</strong>nums = [2,2,1]</p>
32+
33+
<p><strong>输出:</strong>1</p>
34+
</div>
3435

3536
<p><strong class="example">示例 2 :</strong></p>
3637

37-
<pre>
38-
<strong>输入:</strong>nums = [4,1,2,1,2]
39-
<strong>输出:</strong>4
40-
</pre>
38+
<div class="example-block">
39+
<p><strong>输入:</strong>nums = [4,1,2,1,2]</p>
40+
41+
<p><strong>输出:</strong>4</p>
42+
</div>
4143

4244
<p><strong class="example">示例 3 :</strong></p>
4345

44-
<pre>
45-
<strong>输入:</strong>nums = [1]
46-
<strong>输出:</strong>1
47-
</pre>
46+
<div class="example-block">
47+
<p><strong>输入:</strong>nums = [1]</p>
48+
49+
<p><strong>输出:</strong>1</p>
50+
</div>
4851

4952
<p>&nbsp;</p>
5053

solution/0100-0199/0136.Single Number/README_EN.md

+23-9
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,29 @@ tags:
2323

2424
<p>&nbsp;</p>
2525
<p><strong class="example">Example 1:</strong></p>
26-
<pre><strong>Input:</strong> nums = [2,2,1]
27-
<strong>Output:</strong> 1
28-
</pre><p><strong class="example">Example 2:</strong></p>
29-
<pre><strong>Input:</strong> nums = [4,1,2,1,2]
30-
<strong>Output:</strong> 4
31-
</pre><p><strong class="example">Example 3:</strong></p>
32-
<pre><strong>Input:</strong> nums = [1]
33-
<strong>Output:</strong> 1
34-
</pre>
26+
27+
<div class="example-block">
28+
<p><strong>Input:</strong> <span class="example-io">nums = [2,2,1]</span></p>
29+
30+
<p><strong>Output:</strong> <span class="example-io">1</span></p>
31+
</div>
32+
33+
<p><strong class="example">Example 2:</strong></p>
34+
35+
<div class="example-block">
36+
<p><strong>Input:</strong> <span class="example-io">nums = [4,1,2,1,2]</span></p>
37+
38+
<p><strong>Output:</strong> <span class="example-io">4</span></p>
39+
</div>
40+
41+
<p><strong class="example">Example 3:</strong></p>
42+
43+
<div class="example-block">
44+
<p><strong>Input:</strong> <span class="example-io">nums = [1]</span></p>
45+
46+
<p><strong>Output:</strong> <span class="example-io">1</span></p>
47+
</div>
48+
3549
<p>&nbsp;</p>
3650
<p><strong>Constraints:</strong></p>
3751

solution/0200-0299/0268.Missing Number/README.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,33 @@ tags:
3030

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

33-
<pre>
34-
<strong>输入:</strong>nums = [3,0,1]
35-
<strong>输出:</strong>2
36-
<b>解释:</b>n = 3,因为有 3 个数字,所以所有的数字都在范围 [0,3] 内。2 是丢失的数字,因为它没有出现在 nums 中。</pre>
33+
<div class="example-block">
34+
<p><strong>输入:</strong>nums = [3,0,1]</p>
35+
36+
<p><strong>输出:</strong>2</p>
37+
38+
<p><b>解释:</b><code>n = 3</code>,因为有 3 个数字,所以所有的数字都在范围 <code>[0,3]</code> 内。2 是丢失的数字,因为它没有出现在 <code>nums</code> 中。</p>
39+
</div>
3740

3841
<p><strong>示例 2:</strong></p>
3942

40-
<pre>
41-
<strong>输入:</strong>nums = [0,1]
42-
<strong>输出:</strong>2
43-
<b>解释:</b>n = 2,因为有 2 个数字,所以所有的数字都在范围 [0,2] 内。2 是丢失的数字,因为它没有出现在 nums 中。</pre>
43+
<div class="example-block">
44+
<p><strong>输入:</strong>nums = [0,1]</p>
4445

45-
<p><strong>示例 3:</strong></p>
46+
<p><strong>输出:</strong>2</p>
4647

47-
<pre>
48-
<strong>输入:</strong>nums = [9,6,4,2,3,5,7,0,1]
49-
<strong>输出:</strong>8
50-
<b>解释:</b>n = 9,因为有 9 个数字,所以所有的数字都在范围 [0,9] 内。8 是丢失的数字,因为它没有出现在 nums 中。</pre>
48+
<p><b>解释:</b><code>n = 2</code>,因为有 2 个数字,所以所有的数字都在范围 <code>[0,2]</code> 内。2 是丢失的数字,因为它没有出现在 <code>nums</code> 中。</p>
49+
</div>
5150

52-
<p><strong>示例 4:</strong></p>
51+
<p><strong>示例 3:</strong></p>
5352

54-
<pre>
55-
<strong>输入:</strong>nums = [0]
56-
<strong>输出:</strong>1
57-
<b>解释:</b>n = 1,因为有 1 个数字,所以所有的数字都在范围 [0,1] 内。1 是丢失的数字,因为它没有出现在 nums 中。</pre>
53+
<div class="example-block">
54+
<p><strong>输入:</strong>nums = [9,6,4,2,3,5,7,0,1]</p>
5855

59-
<p>&nbsp;</p>
56+
<p><strong>输出:</strong>8</p>
57+
58+
<p><b>解释:</b><code>n = 9</code>,因为有 9 个数字,所以所有的数字都在范围 <code>[0,9]</code> 内。8 是丢失的数字,因为它没有出现在 <code>nums</code> 中。</p>
59+
</div>
6060

6161
<p><strong>提示:</strong></p>
6262

solution/0200-0299/0268.Missing Number/README_EN.md

+45-15
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,57 @@ tags:
2626
<p>&nbsp;</p>
2727
<p><strong class="example">Example 1:</strong></p>
2828

29-
<pre>
30-
<strong>Input:</strong> nums = [3,0,1]
31-
<strong>Output:</strong> 2
32-
<strong>Explanation:</strong> n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.
33-
</pre>
29+
<div class="example-block">
30+
<p><strong>Input:</strong> <span class="example-io">nums = [3,0,1]</span></p>
31+
32+
<p><strong>Output:</strong> <span class="example-io">2</span></p>
33+
34+
<p><strong>Explanation:</strong></p>
35+
36+
<p><code>n = 3</code> since there are 3 numbers, so all numbers are in the range <code>[0,3]</code>. 2 is the missing number in the range since it does not appear in <code>nums</code>.</p>
37+
</div>
3438

3539
<p><strong class="example">Example 2:</strong></p>
3640

37-
<pre>
38-
<strong>Input:</strong> nums = [0,1]
39-
<strong>Output:</strong> 2
40-
<strong>Explanation:</strong> n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums.
41-
</pre>
41+
<div class="example-block">
42+
<p><strong>Input:</strong> <span class="example-io">nums = [0,1]</span></p>
43+
44+
<p><strong>Output:</strong> <span class="example-io">2</span></p>
45+
46+
<p><strong>Explanation:</strong></p>
47+
48+
<p><code>n = 2</code> since there are 2 numbers, so all numbers are in the range <code>[0,2]</code>. 2 is the missing number in the range since it does not appear in <code>nums</code>.</p>
49+
</div>
4250

4351
<p><strong class="example">Example 3:</strong></p>
4452

45-
<pre>
46-
<strong>Input:</strong> nums = [9,6,4,2,3,5,7,0,1]
47-
<strong>Output:</strong> 8
48-
<strong>Explanation:</strong> n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums.
49-
</pre>
53+
<div class="example-block">
54+
<p><strong>Input:</strong> <span class="example-io">nums = [9,6,4,2,3,5,7,0,1]</span></p>
55+
56+
<p><strong>Output:</strong> <span class="example-io">8</span></p>
57+
58+
<p><strong>Explanation:</strong></p>
59+
60+
<p><code>n = 9</code> since there are 9 numbers, so all numbers are in the range <code>[0,9]</code>. 8 is the missing number in the range since it does not appear in <code>nums</code>.</p>
61+
</div>
62+
63+
<div class="simple-translate-system-theme" id="simple-translate">
64+
<div>
65+
<div class="simple-translate-button isShow" style="background-image: url(&quot;moz-extension://8a9ffb6b-7e69-4e93-aae1-436a1448eff6/icons/512.png&quot;); height: 22px; width: 22px; top: 318px; left: 36px;">&nbsp;</div>
66+
67+
<div class="simple-translate-panel " style="width: 300px; height: 200px; top: 0px; left: 0px; font-size: 13px;">
68+
<div class="simple-translate-result-wrapper" style="overflow: hidden;">
69+
<div class="simple-translate-move" draggable="true">&nbsp;</div>
70+
71+
<div class="simple-translate-result-contents">
72+
<p class="simple-translate-result" dir="auto">&nbsp;</p>
73+
74+
<p class="simple-translate-candidate" dir="auto">&nbsp;</p>
75+
</div>
76+
</div>
77+
</div>
78+
</div>
79+
</div>
5080

5181
<p>&nbsp;</p>
5282
<p><strong>Constraints:</strong></p>

solution/0400-0499/0436.Find Right Interval/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ tags:
2020

2121
<p>给你一个区间数组 <code>intervals</code> ,其中&nbsp;<code>intervals[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> ,且每个&nbsp;<code>start<sub>i</sub></code> 都 <strong>不同</strong> 。</p>
2222

23-
<p>区间 <code>i</code> 的 <strong>右侧区间</strong> 可以记作区间 <code>j</code> ,并满足 <code>start<sub>j</sub></code><code>&nbsp;&gt;= end<sub>i</sub></code> ,且 <code>start<sub>j</sub></code> <strong>最小化 </strong>。注意 <code>i</code> 可能等于 <code>j</code> 。</p>
23+
<p>区间 <code>i</code> 的 <strong>右侧区间</strong>&nbsp;是满足 <code>start<sub>j</sub>&nbsp;&gt;= end<sub>i</sub></code>,且 <code>start<sub>j</sub></code> <strong>最小&nbsp;</strong>的区间 <code>j</code>。注意 <code>i</code> 可能等于 <code>j</code> 。</p>
2424

25-
<p>返回一个由每个区间 <code>i</code><strong>右侧区间</strong> &nbsp;<code>intervals</code> 中对应下标组成的数组。如果某个区间 <code>i</code> 不存在对应的 <strong>右侧区间</strong> ,则下标 <code>i</code> 处的值设为 <code>-1</code> 。</p>
25+
<p>返回一个由每个区间 <code>i</code>&nbsp;对应的 <strong>右侧区间</strong> 下标组成的数组。如果某个区间 <code>i</code> 不存在对应的 <strong>右侧区间</strong> ,则下标 <code>i</code> 处的值设为 <code>-1</code> 。</p>
2626
&nbsp;
2727

2828
<p><strong>示例 1:</strong></p>

solution/0500-0599/0588.Design In-Memory File System/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ fileSystem.readContentFromFile(&quot;/a/b/c/d&quot;); // return &quot;hello&quot
7070
<li><code>path</code> and <code>filePath</code>&nbsp;are absolute paths which begin with <code>&#39;/&#39;</code>&nbsp;and do not end with <code>&#39;/&#39;</code>&nbsp;except that the path is just&nbsp;<code>&quot;/&quot;</code>.</li>
7171
<li>You can assume that all directory names and file names only contain lowercase letters, and the same names will not exist in the same directory.</li>
7272
<li>You can assume that all operations will be passed valid parameters, and users will not attempt to retrieve file content or list a directory or file that does not exist.</li>
73+
<li>You can assume that the parent directory for the file in <code>addContentToFile</code> will exist.</li>
7374
<li><code>1 &lt;= content.length &lt;= 50</code></li>
7475
<li>At most <code>300</code> calls will be made to <code>ls</code>, <code>mkdir</code>,&nbsp;<code>addContentToFile</code>, and&nbsp;<code>readContentFromFile</code>.</li>
7576
</ul>

solution/0600-0699/0692.Top K Frequent Words/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ difficulty: 中等
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0692.Top%20K%20Frequent%20Words/README.md
55
tags:
66
- 字典树
7+
- 数组
78
- 哈希表
89
- 字符串
910
- 桶排序

solution/0600-0699/0692.Top K Frequent Words/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ difficulty: Medium
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0692.Top%20K%20Frequent%20Words/README_EN.md
55
tags:
66
- Trie
7+
- Array
78
- Hash Table
89
- String
910
- Bucket Sort

solution/0800-0899/0896.Monotonic Array/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tags:
1818

1919
<p>如果数组是单调递增或单调递减的,那么它是&nbsp;<strong>单调 </strong><em>的</em>。</p>
2020

21-
<p>如果对于所有 <code>i &lt;= j</code>,<code>nums[i] &lt;= nums[j]</code>,那么数组 <code>nums</code> 是单调递增的。 如果对于所有 <code>i &lt;= j</code>,<code>nums[i]&gt; = nums[j]</code>,那么数组 <code>nums</code>&nbsp;是单调递减的。</p>
21+
<p>如果对于所有 <code>i &lt;= j</code>,<code>nums[i] &lt;= nums[j]</code>,那么数组 <code>nums</code> 是单调递增的。 如果对于所有 <code>i &lt;= j</code>,<code>nums[i] &gt;= nums[j]</code>,那么数组 <code>nums</code>&nbsp;是单调递减的。</p>
2222

2323
<p>当给定的数组 <code>nums</code>&nbsp;是单调数组时返回 <code>true</code>,否则返回 <code>false</code>。</p>
2424

solution/0900-0999/0916.Word Subsets/README_EN.md

+18-8
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,27 @@ tags:
3333
<p>&nbsp;</p>
3434
<p><strong class="example">Example 1:</strong></p>
3535

36-
<pre>
37-
<strong>Input:</strong> words1 = [&quot;amazon&quot;,&quot;apple&quot;,&quot;facebook&quot;,&quot;google&quot;,&quot;leetcode&quot;], words2 = [&quot;e&quot;,&quot;o&quot;]
38-
<strong>Output:</strong> [&quot;facebook&quot;,&quot;google&quot;,&quot;leetcode&quot;]
39-
</pre>
36+
<div class="example-block">
37+
<p><strong>Input:</strong> <span class="example-io">words1 = [&quot;amazon&quot;,&quot;apple&quot;,&quot;facebook&quot;,&quot;google&quot;,&quot;leetcode&quot;], words2 = [&quot;e&quot;,&quot;o&quot;]</span></p>
38+
39+
<p><strong>Output:</strong> <span class="example-io">[&quot;facebook&quot;,&quot;google&quot;,&quot;leetcode&quot;]</span></p>
40+
</div>
4041

4142
<p><strong class="example">Example 2:</strong></p>
4243

43-
<pre>
44-
<strong>Input:</strong> words1 = [&quot;amazon&quot;,&quot;apple&quot;,&quot;facebook&quot;,&quot;google&quot;,&quot;leetcode&quot;], words2 = [&quot;l&quot;,&quot;e&quot;]
45-
<strong>Output:</strong> [&quot;apple&quot;,&quot;google&quot;,&quot;leetcode&quot;]
46-
</pre>
44+
<div class="example-block">
45+
<p><strong>Input:</strong> <span class="example-io">words1 = [&quot;amazon&quot;,&quot;apple&quot;,&quot;facebook&quot;,&quot;google&quot;,&quot;leetcode&quot;], words2 = [&quot;lc&quot;,&quot;eo&quot;]</span></p>
46+
47+
<p><strong>Output:</strong> <span class="example-io">[&quot;leetcode&quot;]</span></p>
48+
</div>
49+
50+
<p><strong class="example">Example 3:</strong></p>
51+
52+
<div class="example-block">
53+
<p><strong>Input:</strong> <span class="example-io">words1 = [&quot;acaac&quot;,&quot;cccbb&quot;,&quot;aacbb&quot;,&quot;caacc&quot;,&quot;bcbbb&quot;], words2 = [&quot;c&quot;,&quot;cc&quot;,&quot;b&quot;]</span></p>
54+
55+
<p><strong>Output:</strong> <span class="example-io">[&quot;cccbb&quot;]</span></p>
56+
</div>
4757

4858
<p>&nbsp;</p>
4959
<p><strong>Constraints:</strong></p>

solution/1300-1399/1352.Product of the Last K Numbers/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ rating: 1473
66
source: 第 176 场周赛 Q2
77
tags:
88
- 设计
9-
- 队列
109
- 数组
1110
- 数学
1211
- 数据流
12+
- 前缀和
1313
---
1414

1515
<!-- problem:start -->

solution/1300-1399/1352.Product of the Last K Numbers/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ rating: 1473
66
source: Weekly Contest 176 Q2
77
tags:
88
- Design
9-
- Queue
109
- Array
1110
- Math
1211
- Data Stream
12+
- Prefix Sum
1313
---
1414

1515
<!-- problem:start -->

solution/1400-1499/1400.Construct K Palindrome Strings/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ tags:
2121

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

24-
<p>Given a string <code>s</code> and an integer <code>k</code>, return <code>true</code> <em>if you can use all the characters in </em><code>s</code><em> to construct </em><code>k</code><em> palindrome strings or </em><code>false</code><em> otherwise</em>.</p>
24+
<p>Given a string <code>s</code> and an integer <code>k</code>, return <code>true</code> if you can use all the characters in <code>s</code> to construct <code>k</code> <span data-keyword="palindrome-string">palindrome strings</span> or <code>false</code> otherwise.</p>
2525

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

solution/1700-1799/1755.Closest Subsequence Sum/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ tags:
1010
- 双指针
1111
- 动态规划
1212
- 状态压缩
13+
- 排序
1314
---
1415

1516
<!-- problem:start -->

solution/1700-1799/1755.Closest Subsequence Sum/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ tags:
1010
- Two Pointers
1111
- Dynamic Programming
1212
- Bitmask
13+
- Sorting
1314
---
1415

1516
<!-- problem:start -->

solution/2200-2299/2271.Maximum White Tiles Covered by a Carpet/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ tags:
1010
- 二分查找
1111
- 前缀和
1212
- 排序
13+
- 滑动窗口
1314
---
1415

1516
<!-- problem:start -->

solution/2200-2299/2271.Maximum White Tiles Covered by a Carpet/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ tags:
1010
- Binary Search
1111
- Prefix Sum
1212
- Sorting
13+
- Sliding Window
1314
---
1415

1516
<!-- problem:start -->

solution/2400-2499/2468.Split Message Based on Limit/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source: 第 91 场双周赛 Q4
77
tags:
88
- 字符串
99
- 二分查找
10+
- 枚举
1011
---
1112

1213
<!-- problem:start -->

solution/2400-2499/2468.Split Message Based on Limit/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source: Biweekly Contest 91 Q4
77
tags:
88
- String
99
- Binary Search
10+
- Enumeration
1011
---
1112

1213
<!-- problem:start -->

0 commit comments

Comments
 (0)