Skip to content

Commit 8b09d75

Browse files
authored
feat: update lc problems (doocs#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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 15 additions & 12 deletions
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

Lines changed: 23 additions & 9 deletions
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

Lines changed: 19 additions & 19 deletions
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

Lines changed: 45 additions & 15 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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
- 桶排序

0 commit comments

Comments
 (0)