Skip to content

Commit d28b39b

Browse files
authored
feat: update lc problems (#3542)
1 parent f388d35 commit d28b39b

File tree

28 files changed

+217
-189
lines changed

28 files changed

+217
-189
lines changed

solution/0000-0099/0046.Permutations/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tags:
1717

1818
<!-- description:start -->
1919

20-
<p>Given an array <code>nums</code> of distinct integers, return <em>all the possible permutations</em>. You can return the answer in <strong>any order</strong>.</p>
20+
<p>Given an array <code>nums</code> of distinct integers, return all the possible <span data-keyword="permutation-array">permutations</span>. You can return the answer in <strong>any order</strong>.</p>
2121

2222
<p>&nbsp;</p>
2323
<p><strong class="example">Example 1:</strong></p>

solution/0200-0299/0241.Different Ways to Add Parentheses/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ tags:
5757
<li><code>1 &lt;= expression.length &lt;= 20</code></li>
5858
<li><code>expression</code> 由数字和算符 <code>'+'</code>、<code>'-'</code> 和 <code>'*'</code> 组成。</li>
5959
<li>输入表达式中的所有整数值在范围 <code>[0, 99]</code>&nbsp;</li>
60+
<li>输入表达式中的所有整数都没有前导&nbsp;<code>'-'</code>&nbsp;或&nbsp;<code>'+'</code> 表示符号。</li>
6061
</ul>
6162

6263
<!-- description:end -->

solution/0200-0299/0241.Different Ways to Add Parentheses/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ tags:
5555
<li><code>1 &lt;= expression.length &lt;= 20</code></li>
5656
<li><code>expression</code> consists of digits and the operator <code>&#39;+&#39;</code>, <code>&#39;-&#39;</code>, and <code>&#39;*&#39;</code>.</li>
5757
<li>All the integer values in the input expression are in the range <code>[0, 99]</code>.</li>
58+
<li>The integer values in the input expression do not have a leading <code>&#39;-&#39;</code> or <code>&#39;+&#39;</code> denoting the sign.</li>
5859
</ul>
5960

6061
<!-- description:end -->

solution/0200-0299/0287.Find the Duplicate Number/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tags:
2323

2424
<p>There is only <strong>one repeated number</strong> in <code>nums</code>, return <em>this&nbsp;repeated&nbsp;number</em>.</p>
2525

26-
<p>You must solve the problem <strong>without</strong> modifying the array <code>nums</code>&nbsp;and uses only constant extra space.</p>
26+
<p>You must solve the problem <strong>without</strong> modifying the array <code>nums</code>&nbsp;and using only constant extra space.</p>
2727

2828
<p>&nbsp;</p>
2929
<p><strong class="example">Example 1:</strong></p>

solution/0300-0399/0357.Count Numbers with Unique Digits/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tags:
2929
<pre>
3030
<strong>输入:</strong>n = 2
3131
<strong>输出:</strong>91
32-
<strong>解释:</strong>答案应为除去 <code>11、22、33、44、55、66、77、88、99 </code>外,在 0 ≤ x &lt; 100 范围内的所有数字。
32+
<strong>解释:</strong>答案应为除去 <code>11、22、33、44、55、66、77、88、99 </code>外,在 0 ≤ x &lt; 100 范围内的所有数字。
3333
</pre>
3434

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

solution/0400-0499/0438.Find All Anagrams in a String/README.md

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

1919
<!-- description:start -->
2020

21-
<p>给定两个字符串&nbsp;<code>s</code>&nbsp;和 <code>p</code>,找到&nbsp;<code>s</code><strong>&nbsp;</strong>中所有&nbsp;<code>p</code><strong>&nbsp;</strong>的&nbsp;<strong>异位词&nbsp;</strong>的子串,返回这些子串的起始索引。不考虑答案输出的顺序。</p>
22-
23-
<p><strong>异位词 </strong>指由相同字母重排列形成的字符串(包括相同的字符串)。</p>
21+
<p>给定两个字符串&nbsp;<code>s</code>&nbsp;和 <code>p</code>,找到&nbsp;<code>s</code><strong>&nbsp;</strong>中所有&nbsp;<code>p</code><strong>&nbsp;</strong>的&nbsp;<strong><span data-keyword="anagram">异位词</span>&nbsp;</strong>的子串,返回这些子串的起始索引。不考虑答案输出的顺序。</p>
2422

2523
<p>&nbsp;</p>
2624

solution/0400-0499/0438.Find All Anagrams in a String/README_EN.md

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

1919
<!-- description:start -->
2020

21-
<p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>&#39;s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p>
22-
23-
<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.</p>
21+
<p>Given two strings <code>s</code> and <code>p</code>, return an array of all the start indices of <code>p</code>&#39;s <span data-keyword="anagram">anagrams</span> in <code>s</code>. You may return the answer in <strong>any order</strong>.</p>
2422

2523
<p>&nbsp;</p>
2624
<p><strong class="example">Example 1:</strong></p>

solution/0500-0599/0567.Permutation in String/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tags:
1919

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

22-
<p>给你两个字符串&nbsp;<code>s1</code>&nbsp;&nbsp;<code>s2</code> ,写一个函数来判断 <code>s2</code> 是否包含 <code>s1</code><strong>&nbsp;</strong>的排列。如果是,返回 <code>true</code> ;否则,返回 <code>false</code> 。</p>
22+
<p>给你两个字符串&nbsp;<code>s1</code>&nbsp;&nbsp;<code>s2</code> ,写一个函数来判断 <code>s2</code> 是否包含 <code>s1</code><strong>&nbsp;</strong>的 <span data-keyword="permutation-string">排列</span>。如果是,返回 <code>true</code> ;否则,返回 <code>false</code> 。</p>
2323

2424
<p>换句话说,<code>s1</code> 的排列之一是 <code>s2</code> 的 <strong>子串</strong> 。</p>
2525

solution/0500-0599/0567.Permutation in String/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tags:
1919

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

22-
<p>Given two strings <code>s1</code> and <code>s2</code>, return <code>true</code><em> if </em><code>s2</code><em> contains a permutation of </em><code>s1</code><em>, or </em><code>false</code><em> otherwise</em>.</p>
22+
<p>Given two strings <code>s1</code> and <code>s2</code>, return <code>true</code> if <code>s2</code> contains a <span data-keyword="permutation-string">permutation</span> of <code>s1</code>, or <code>false</code> otherwise.</p>
2323

2424
<p>In other words, return <code>true</code> if one of <code>s1</code>&#39;s permutations is the substring of <code>s2</code>.</p>
2525

solution/0600-0699/0600.Non-negative Integers without Consecutive Ones/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tags:
2525
<pre>
2626
<strong>输入:</strong> n = 5
2727
<strong>输出:</strong> 5
28-
<strong>解释:</strong>
28+
<strong>解释:</strong>
2929
下面列出范围在 [0, 5] 的非负整数与其对应的二进制表示:
3030
0 : 0
3131
1 : 1

solution/0600-0699/0600.Non-negative Integers without Consecutive Ones/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Here are the non-negative integers &lt;= 5 with their corresponding binary repre
3232
3 : 11
3333
4 : 100
3434
5 : 101
35-
Among them, only integer 3 disobeys the rule (two consecutive ones) and the other 5 satisfy the rule.
35+
Among them, only integer 3 disobeys the rule (two consecutive ones) and the other 5 satisfy the rule.
3636
</pre>
3737

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

solution/0600-0699/0666.Path Sum IV/README_EN.md

+31-19
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,48 @@ tags:
2020

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

23-
<p>If the depth of a tree is smaller than <code>5</code>, then this tree can be represented by an array of three-digit integers. For each integer in this array:</p>
23+
<p>If the depth of a tree is smaller than <code>5</code>, then this tree can be represented by an array of three-digit integers. You are given an <strong>ascending </strong>array <code>nums</code> consisting of three-digit integers representing a binary tree with a depth smaller than <code>5</code>, where for each integer:</p>
2424

2525
<ul>
26-
<li>The hundreds digit represents the depth <code>d</code> of this node where <code>1 &lt;= d &lt;= 4</code>.</li>
27-
<li>The tens digit represents the position <code>p</code> of this node in the level it belongs to where <code>1 &lt;= p &lt;= 8</code>. The position is the same as that in a full binary tree.</li>
28-
<li>The units digit represents the value <code>v</code> of this node where <code>0 &lt;= v &lt;= 9</code>.</li>
26+
<li>The hundreds digit represents the depth <code>d</code> of this node, where <code>1 &lt;= d &lt;= 4</code>.</li>
27+
<li>The tens digit represents the position <code>p</code> of this node within its level, where <code>1 &lt;= p &lt;= 8</code>, corresponding to its position in a <strong>full binary tree</strong>.</li>
28+
<li>The units digit represents the value <code>v</code> of this node, where <code>0 &lt;= v &lt;= 9</code>.</li>
2929
</ul>
3030

31-
<p>Given an array of <strong>ascending</strong> three-digit integers <code>nums</code> representing a binary tree with a depth smaller than <code>5</code>, return <em>the sum of all paths from the root towards the leaves</em>.</p>
31+
<p>Return the <strong>sum</strong> of <strong>all paths</strong> from the <strong>root</strong> towards the <strong>leaves</strong>.</p>
3232

3333
<p>It is <strong>guaranteed</strong> that the given array represents a valid connected binary tree.</p>
3434

3535
<p>&nbsp;</p>
3636
<p><strong class="example">Example 1:</strong></p>
37-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0600-0699/0666.Path%20Sum%20IV/images/pathsum4-1-tree.jpg" style="width: 212px; height: 183px;" />
38-
<pre>
39-
<strong>Input:</strong> nums = [113,215,221]
40-
<strong>Output:</strong> 12
41-
<strong>Explanation:</strong> The tree that the list represents is shown.
42-
The path sum is (3 + 5) + (3 + 1) = 12.
43-
</pre>
37+
38+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0600-0699/0666.Path%20Sum%20IV/images/pathsum4-1-tree.jpg" style="width: 212px; height: 183px;" /></p>
39+
40+
<div class="example-block">
41+
<p><strong>Input:</strong> <span class="example-io">nums = [113,215,221]</span></p>
42+
43+
<p><strong>Output:</strong> <span class="example-io">12</span></p>
44+
45+
<p><strong>Explanation:</strong></p>
46+
47+
<p>The tree that the list represents is shown.<br />
48+
The path sum is (3 + 5) + (3 + 1) = 12.</p>
49+
</div>
4450

4551
<p><strong class="example">Example 2:</strong></p>
46-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0600-0699/0666.Path%20Sum%20IV/images/pathsum4-2-tree.jpg" style="width: 132px; height: 183px;" />
47-
<pre>
48-
<strong>Input:</strong> nums = [113,221]
49-
<strong>Output:</strong> 4
50-
<strong>Explanation:</strong> The tree that the list represents is shown.
51-
The path sum is (3 + 1) = 4.
52-
</pre>
52+
53+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0600-0699/0666.Path%20Sum%20IV/images/pathsum4-2-tree.jpg" style="width: 132px; height: 183px;" /></p>
54+
55+
<div class="example-block">
56+
<p><strong>Input:</strong> <span class="example-io">nums = [113,221]</span></p>
57+
58+
<p><strong>Output:</strong> <span class="example-io">4</span></p>
59+
60+
<p><strong>Explanation:</strong></p>
61+
62+
<p>The tree that the list represents is shown.&nbsp;<br />
63+
The path sum is (3 + 1) = 4.</p>
64+
</div>
5365

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

solution/0700-0799/0733.Flood Fill/README_EN.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@ tags:
1919

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

22-
<p>An image is represented by an <code>m x n</code> integer grid <code>image</code> where <code>image[i][j]</code> represents the pixel value of the image.</p>
22+
<p>You are given an image represented by an <code>m x n</code> grid of integers <code>image</code>, where <code>image[i][j]</code> represents the pixel value of the image. You are also given three integers <code>sr</code>, <code>sc</code>, and <code>color</code>. Your task is to perform a <strong>flood fill</strong> on the image starting from the pixel <code>image[sr][sc]</code>.</p>
2323

24-
<p>You are also given three integers <code>sr</code>, <code>sc</code>, and <code>color</code>. You should perform a <strong>flood fill</strong> on the image starting from the pixel <code>image[sr][sc]</code>.</p>
24+
<p>To perform a <strong>flood fill</strong>:</p>
2525

26-
<p>To perform a <strong>flood fill</strong>, consider the starting pixel, plus any pixels connected <strong>4-directionally</strong> to the starting pixel of the same color as the starting pixel, plus any pixels connected <strong>4-directionally</strong> to those pixels (also with the same color), and so on. Replace the color of all of the aforementioned pixels with <code>color</code>.</p>
26+
<ol>
27+
<li>Begin with the starting pixel and change its color to <code>color</code>.</li>
28+
<li>Perform the same process for each pixel that is <strong>directly adjacent</strong> (pixels that share a side with the original pixel, either horizontally or vertically) and shares the <strong>same color</strong> as the starting pixel.</li>
29+
<li>Keep <strong>repeating</strong> this process by checking neighboring pixels of the <em>updated</em> pixels&nbsp;and modifying their color if it matches the original color of the starting pixel.</li>
30+
<li>The process <strong>stops</strong> when there are <strong>no more</strong> adjacent pixels of the original color to update.</li>
31+
</ol>
2732

28-
<p>Return <em>the modified image after performing the flood fill</em>.</p>
33+
<p>Return the <strong>modified</strong> image after performing the flood fill.</p>
2934

3035
<p>&nbsp;</p>
3136
<p><strong class="example">Example 1:</strong></p>
@@ -41,7 +46,7 @@ tags:
4146

4247
<p>From the center of the image with position <code>(sr, sc) = (1, 1)</code> (i.e., the red pixel), all pixels connected by a path of the same color as the starting pixel (i.e., the blue pixels) are colored with the new color.</p>
4348

44-
<p>Note the bottom corner is <strong>not</strong> colored 2, because it is not 4-directionally connected to the starting pixel.</p>
49+
<p>Note the bottom corner is <strong>not</strong> colored 2, because it is not horizontally or vertically connected to the starting pixel.</p>
4550
</div>
4651

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

solution/0900-0999/0912.Sort an Array/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ tags:
2525

2626
<p>给你一个整数数组&nbsp;<code>nums</code>,请你将该数组升序排列。</p>
2727

28+
<p>你必须在 <strong>不使用任何内置函数</strong> 的情况下解决问题,时间复杂度为 <code>O(nlog(n))</code>,并且空间复杂度尽可能小。</p>
29+
2830
<p>&nbsp;</p>
2931

3032
<ol>

solution/1800-1899/1813.Sentence Similarity III/README_EN.md

+37-18
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,55 @@ tags:
2020

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

23-
<p>A sentence is a list of words that are separated by a single space with no leading or trailing spaces. For example, <code>&quot;Hello World&quot;</code>, <code>&quot;HELLO&quot;</code>, <code>&quot;hello world hello world&quot;</code> are all sentences. Words consist of <strong>only</strong> uppercase and lowercase English letters.</p>
23+
<p>You are given two strings <code>sentence1</code> and <code>sentence2</code>, each representing a <strong>sentence</strong> composed of words. A sentence is a list of <strong>words</strong> that are separated by a <strong>single</strong> space with no leading or trailing spaces. Each word consists of only uppercase and lowercase English characters.</p>
2424

25-
<p>Two sentences <code>sentence1</code> and <code>sentence2</code> are <strong>similar</strong> if it is possible to insert an arbitrary sentence <strong>(possibly empty)</strong> inside one of these sentences such that the two sentences become equal. For example, <code>sentence1 = &quot;Hello my name is Jane&quot;</code> and <code>sentence2 = &quot;Hello Jane&quot;</code> can be made equal by inserting <code>&quot;my name is&quot;</code> between <code>&quot;Hello&quot;</code> and <code>&quot;Jane&quot;</code> in <code>sentence2</code>.</p>
25+
<p>Two sentences <code>s1</code> and <code>s2</code> are considered <strong>similar</strong> if it is possible to insert an arbitrary sentence (<em>possibly empty</em>) inside one of these sentences such that the two sentences become equal. <strong>Note</strong> that the inserted sentence must be separated from existing words by spaces.</p>
2626

27-
<p>Given two sentences <code>sentence1</code> and <code>sentence2</code>, return <code>true</code> <em>if </em><code>sentence1</code> <em>and </em><code>sentence2</code> <em>are similar.</em> Otherwise, return <code>false</code>.</p>
27+
<p>For example,</p>
28+
29+
<ul>
30+
<li><code>s1 = &quot;Hello Jane&quot;</code> and <code>s2 = &quot;Hello my name is Jane&quot;</code> can be made equal by inserting <code>&quot;my name is&quot;</code> between <code>&quot;Hello&quot;</code><font face="monospace"> </font>and <code>&quot;Jane&quot;</code><font face="monospace"> in s1.</font></li>
31+
<li><font face="monospace"><code>s1 = &quot;Frog cool&quot;</code> </font>and<font face="monospace"> <code>s2 = &quot;Frogs are cool&quot;</code> </font>are <strong>not</strong> similar, since although there is a sentence <code>&quot;s are&quot;</code> inserted into <code>s1</code>, it is not separated from <code>&quot;Frog&quot;</code> by a space.</li>
32+
</ul>
33+
34+
<p>Given two sentences <code>sentence1</code> and <code>sentence2</code>, return <strong>true</strong> if <code>sentence1</code> and <code>sentence2</code> are <strong>similar</strong>. Otherwise, return <strong>false</strong>.</p>
2835

2936
<p>&nbsp;</p>
3037
<p><strong class="example">Example 1:</strong></p>
3138

32-
<pre>
33-
<strong>Input:</strong> sentence1 = &quot;My name is Haley&quot;, sentence2 = &quot;My Haley&quot;
34-
<strong>Output:</strong> true
35-
<strong>Explanation:</strong> sentence2 can be turned to sentence1 by inserting &quot;name is&quot; between &quot;My&quot; and &quot;Haley&quot;.
36-
</pre>
39+
<div class="example-block">
40+
<p><strong>Input:</strong> <span class="example-io">sentence1 = &quot;My name is Haley&quot;, sentence2 = &quot;My Haley&quot;</span></p>
41+
42+
<p><strong>Output:</strong> <span class="example-io">true</span></p>
43+
44+
<p><strong>Explanation:</strong></p>
45+
46+
<p><code>sentence2</code> can be turned to <code>sentence1</code> by inserting &quot;name is&quot; between &quot;My&quot; and &quot;Haley&quot;.</p>
47+
</div>
3748

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

40-
<pre>
41-
<strong>Input:</strong> sentence1 = &quot;of&quot;, sentence2 = &quot;A lot of words&quot;
42-
<strong>Output:</strong> false
43-
<strong>Explanation: </strong>No single sentence can be inserted inside one of the sentences to make it equal to the other.
44-
</pre>
51+
<div class="example-block">
52+
<p><strong>Input:</strong> <span class="example-io">sentence1 = &quot;of&quot;, sentence2 = &quot;A lot of words&quot;</span></p>
53+
54+
<p><strong>Output:</strong> <span class="example-io">false</span></p>
55+
56+
<p><strong>Explanation:</strong></p>
57+
58+
<p>No single sentence can be inserted inside one of the sentences to make it equal to the other.</p>
59+
</div>
4560

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

48-
<pre>
49-
<strong>Input:</strong> sentence1 = &quot;Eating right now&quot;, sentence2 = &quot;Eating&quot;
50-
<strong>Output:</strong> true
51-
<strong>Explanation:</strong> sentence2 can be turned to sentence1 by inserting &quot;right now&quot; at the end of the sentence.
52-
</pre>
63+
<div class="example-block">
64+
<p><strong>Input:</strong> <span class="example-io">sentence1 = &quot;Eating right now&quot;, sentence2 = &quot;Eating&quot;</span></p>
65+
66+
<p><strong>Output:</strong> <span class="example-io">true</span></p>
67+
68+
<p><strong>Explanation:</strong></p>
69+
70+
<p><code>sentence2</code> can be turned to <code>sentence1</code> by inserting &quot;right now&quot; at the end of the sentence.</p>
71+
</div>
5372

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

0 commit comments

Comments
 (0)