Skip to content

Commit

Permalink
feat: update lc problems
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglbme committed Jan 13, 2025
1 parent 636aad9 commit 33e5b42
Show file tree
Hide file tree
Showing 80 changed files with 451 additions and 207 deletions.
2 changes: 1 addition & 1 deletion solution/0000-0099/0014.Longest Common Prefix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tags:
<ul>
<li><code>1 &lt;= strs.length &lt;= 200</code></li>
<li><code>0 &lt;= strs[i].length &lt;= 200</code></li>
<li><code>strs[i]</code> 仅由小写英文字母组成</li>
<li><code>strs[i]</code>&nbsp;如果非空,则仅由小写英文字母组成</li>
</ul>

<!-- description:end -->
Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0014.Longest Common Prefix/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tags:
<ul>
<li><code>1 &lt;= strs.length &lt;= 200</code></li>
<li><code>0 &lt;= strs[i].length &lt;= 200</code></li>
<li><code>strs[i]</code> consists of only lowercase English letters.</li>
<li><code>strs[i]</code> consists of only lowercase English letters if it is non-empty.</li>
</ul>

<!-- description:end -->
Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0045.Jump Game II/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tags:

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

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

<ul>
<li><code>0 &lt;= j &lt;= nums[i]</code>&nbsp;</li>
Expand Down
27 changes: 15 additions & 12 deletions solution/0100-0199/0136.Single Number/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,27 @@ tags:

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

<pre>
<strong>输入:</strong>nums = [2,2,1]
<strong>输出:</strong>1
</pre>
<div class="example-block">
<p><strong>输入:</strong>nums = [2,2,1]</p>

<p><strong>输出:</strong>1</p>
</div>

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

<pre>
<strong>输入:</strong>nums = [4,1,2,1,2]
<strong>输出:</strong>4
</pre>
<div class="example-block">
<p><strong>输入:</strong>nums = [4,1,2,1,2]</p>

<p><strong>输出:</strong>4</p>
</div>

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

<pre>
<strong>输入:</strong>nums = [1]
<strong>输出:</strong>1
</pre>
<div class="example-block">
<p><strong>输入:</strong>nums = [1]</p>

<p><strong>输出:</strong>1</p>
</div>

<p>&nbsp;</p>

Expand Down
32 changes: 23 additions & 9 deletions solution/0100-0199/0136.Single Number/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,29 @@ tags:

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> nums = [2,2,1]
<strong>Output:</strong> 1
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> nums = [4,1,2,1,2]
<strong>Output:</strong> 4
</pre><p><strong class="example">Example 3:</strong></p>
<pre><strong>Input:</strong> nums = [1]
<strong>Output:</strong> 1
</pre>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [2,2,1]</span></p>

<p><strong>Output:</strong> <span class="example-io">1</span></p>
</div>

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

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [4,1,2,1,2]</span></p>

<p><strong>Output:</strong> <span class="example-io">4</span></p>
</div>

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

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [1]</span></p>

<p><strong>Output:</strong> <span class="example-io">1</span></p>
</div>

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

Expand Down
38 changes: 19 additions & 19 deletions solution/0200-0299/0268.Missing Number/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,33 @@ tags:

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

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

<p><strong>输出:</strong>2</p>

<p><b>解释:</b><code>n = 3</code>,因为有 3 个数字,所以所有的数字都在范围 <code>[0,3]</code> 内。2 是丢失的数字,因为它没有出现在 <code>nums</code> 中。</p>
</div>

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

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

<p><strong>示例 3:</strong></p>
<p><strong>输出:</strong>2</p>

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

<p><strong>示例 4:</strong></p>
<p><strong>示例 3:</strong></p>

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

<p>&nbsp;</p>
<p><strong>输出:</strong>8</p>

<p><b>解释:</b><code>n = 9</code>,因为有 9 个数字,所以所有的数字都在范围 <code>[0,9]</code> 内。8 是丢失的数字,因为它没有出现在 <code>nums</code> 中。</p>
</div>

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

Expand Down
60 changes: 45 additions & 15 deletions solution/0200-0299/0268.Missing Number/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,57 @@ tags:
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [3,0,1]
<strong>Output:</strong> 2
<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.
</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [3,0,1]</span></p>

<p><strong>Output:</strong> <span class="example-io">2</span></p>

<p><strong>Explanation:</strong></p>

<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>
</div>

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

<pre>
<strong>Input:</strong> nums = [0,1]
<strong>Output:</strong> 2
<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.
</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [0,1]</span></p>

<p><strong>Output:</strong> <span class="example-io">2</span></p>

<p><strong>Explanation:</strong></p>

<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>
</div>

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

<pre>
<strong>Input:</strong> nums = [9,6,4,2,3,5,7,0,1]
<strong>Output:</strong> 8
<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.
</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [9,6,4,2,3,5,7,0,1]</span></p>

<p><strong>Output:</strong> <span class="example-io">8</span></p>

<p><strong>Explanation:</strong></p>

<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>
</div>

<div class="simple-translate-system-theme" id="simple-translate">
<div>
<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>

<div class="simple-translate-panel " style="width: 300px; height: 200px; top: 0px; left: 0px; font-size: 13px;">
<div class="simple-translate-result-wrapper" style="overflow: hidden;">
<div class="simple-translate-move" draggable="true">&nbsp;</div>

<div class="simple-translate-result-contents">
<p class="simple-translate-result" dir="auto">&nbsp;</p>

<p class="simple-translate-candidate" dir="auto">&nbsp;</p>
</div>
</div>
</div>
</div>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
Expand Down
4 changes: 2 additions & 2 deletions solution/0400-0499/0436.Find Right Interval/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ tags:

<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>

<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>
<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>

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

<p><strong>示例 1:</strong></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ fileSystem.readContentFromFile(&quot;/a/b/c/d&quot;); // return &quot;hello&quot
<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>
<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>
<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>
<li>You can assume that the parent directory for the file in <code>addContentToFile</code> will exist.</li>
<li><code>1 &lt;= content.length &lt;= 50</code></li>
<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>
</ul>
Expand Down
1 change: 1 addition & 0 deletions solution/0600-0699/0692.Top K Frequent Words/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0692.Top%20K%20Frequent%20Words/README.md
tags:
- 字典树
- 数组
- 哈希表
- 字符串
- 桶排序
Expand Down
1 change: 1 addition & 0 deletions solution/0600-0699/0692.Top K Frequent Words/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0692.Top%20K%20Frequent%20Words/README_EN.md
tags:
- Trie
- Array
- Hash Table
- String
- Bucket Sort
Expand Down
2 changes: 1 addition & 1 deletion solution/0800-0899/0896.Monotonic Array/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tags:

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

<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>
<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>

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

Expand Down
26 changes: 18 additions & 8 deletions solution/0900-0999/0916.Word Subsets/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,27 @@ tags:
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<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;]
<strong>Output:</strong> [&quot;facebook&quot;,&quot;google&quot;,&quot;leetcode&quot;]
</pre>
<div class="example-block">
<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>

<p><strong>Output:</strong> <span class="example-io">[&quot;facebook&quot;,&quot;google&quot;,&quot;leetcode&quot;]</span></p>
</div>

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

<pre>
<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;]
<strong>Output:</strong> [&quot;apple&quot;,&quot;google&quot;,&quot;leetcode&quot;]
</pre>
<div class="example-block">
<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>

<p><strong>Output:</strong> <span class="example-io">[&quot;leetcode&quot;]</span></p>
</div>

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

<div class="example-block">
<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>

<p><strong>Output:</strong> <span class="example-io">[&quot;cccbb&quot;]</span></p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ rating: 1473
source: 第 176 场周赛 Q2
tags:
- 设计
- 队列
- 数组
- 数学
- 数据流
- 前缀和
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ rating: 1473
source: Weekly Contest 176 Q2
tags:
- Design
- Queue
- Array
- Math
- Data Stream
- Prefix Sum
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tags:

<!-- description:start -->

<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>
<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>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
Expand Down
1 change: 1 addition & 0 deletions solution/1700-1799/1755.Closest Subsequence Sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tags:
- 双指针
- 动态规划
- 状态压缩
- 排序
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tags:
- Two Pointers
- Dynamic Programming
- Bitmask
- Sorting
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tags:
- 二分查找
- 前缀和
- 排序
- 滑动窗口
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tags:
- Binary Search
- Prefix Sum
- Sorting
- Sliding Window
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ source: 第 91 场双周赛 Q4
tags:
- 字符串
- 二分查找
- 枚举
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ source: Biweekly Contest 91 Q4
tags:
- String
- Binary Search
- Enumeration
---

<!-- problem:start -->
Expand Down
Loading

0 comments on commit 33e5b42

Please sign in to comment.