Skip to content

Commit 7b45b83

Browse files
committed
feat: update lc problems
1 parent 99a394b commit 7b45b83

File tree

114 files changed

+3580
-278
lines changed

Some content is hidden

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

114 files changed

+3580
-278
lines changed

solution/0100-0199/0195.Tenth Line/README_EN.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,41 @@ tags:
2323
<p>Assume that <code>file.txt</code> has the following content:</p>
2424

2525
<pre>
26+
2627
Line 1
28+
2729
Line 2
30+
2831
Line 3
32+
2933
Line 4
34+
3035
Line 5
36+
3137
Line 6
38+
3239
Line 7
40+
3341
Line 8
42+
3443
Line 9
44+
3545
Line 10
46+
3647
</pre>
3748

3849
<p>Your script should output the tenth line, which is:</p>
3950

4051
<pre>
52+
4153
Line 10
54+
4255
</pre>
4356

4457
<div class="spoilers"><b>Note:</b><br />
58+
4559
1. If the file contains less than 10 lines, what should you output?<br />
60+
4661
2. There&#39;s at least three different solutions. Try to explore all possibilities.</div>
4762

4863
<!-- description:end -->

solution/0600-0699/0636.Exclusive Time of Functions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ tags:
7373

7474
<ul>
7575
<li><code>1 &lt;= n &lt;= 100</code></li>
76-
<li><code>1 &lt;= logs.length &lt;= 500</code></li>
76+
<li><code>2 &lt;= logs.length &lt;= 500</code></li>
7777
<li><code>0 &lt;= function_id &lt; n</code></li>
7878
<li><code>0 &lt;= timestamp &lt;= 10<sup>9</sup></code></li>
7979
<li>两个开始事件不会在同一时间戳发生</li>

solution/0600-0699/0636.Exclusive Time of Functions/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ So function 0 spends 2 + 4 + 1 = 7 units of total time executing, and function 1
7373

7474
<ul>
7575
<li><code>1 &lt;= n &lt;= 100</code></li>
76-
<li><code>1 &lt;= logs.length &lt;= 500</code></li>
76+
<li><code>2 &lt;= logs.length &lt;= 500</code></li>
7777
<li><code>0 &lt;= function_id &lt; n</code></li>
7878
<li><code>0 &lt;= timestamp &lt;= 10<sup>9</sup></code></li>
7979
<li>No two start events will happen at the same timestamp.</li>

solution/0700-0799/0790.Domino and Tromino Tiling/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tags:
2828
<pre>
2929
<strong>Input:</strong> n = 3
3030
<strong>Output:</strong> 5
31-
<strong>Explanation:</strong> The five different ways are show above.
31+
<strong>Explanation:</strong> The five different ways are shown above.
3232
</pre>
3333

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

solution/0700-0799/0799.Champagne Tower/README_EN.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,51 @@ tags:
2727
<p>Now after pouring some non-negative integer cups of champagne, return how full the <code>j<sup>th</sup></code> glass in the <code>i<sup>th</sup></code> row is (both <code>i</code> and <code>j</code> are 0-indexed.)</p>
2828

2929
<p>&nbsp;</p>
30+
3031
<p><strong class="example">Example 1:</strong></p>
3132

3233
<pre>
34+
3335
<strong>Input:</strong> poured = 1, query_row = 1, query_glass = 1
36+
3437
<strong>Output:</strong> 0.00000
38+
3539
<strong>Explanation:</strong> We poured 1 cup of champange to the top glass of the tower (which is indexed as (0, 0)). There will be no excess liquid so all the glasses under the top glass will remain empty.
40+
3641
</pre>
3742

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

4045
<pre>
46+
4147
<strong>Input:</strong> poured = 2, query_row = 1, query_glass = 1
48+
4249
<strong>Output:</strong> 0.50000
50+
4351
<strong>Explanation:</strong> We poured 2 cups of champange to the top glass of the tower (which is indexed as (0, 0)). There is one cup of excess liquid. The glass indexed as (1, 0) and the glass indexed as (1, 1) will share the excess liquid equally, and each will get half cup of champange.
52+
4453
</pre>
4554

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

4857
<pre>
58+
4959
<strong>Input:</strong> poured = 100000009, query_row = 33, query_glass = 17
60+
5061
<strong>Output:</strong> 1.00000
62+
5163
</pre>
5264

5365
<p>&nbsp;</p>
66+
5467
<p><strong>Constraints:</strong></p>
5568

5669
<ul>
57-
<li><code>0 &lt;=&nbsp;poured &lt;= 10<sup>9</sup></code></li>
58-
<li><code>0 &lt;= query_glass &lt;= query_row&nbsp;&lt; 100</code></li>
70+
71+
<li><code>0 &lt;=&nbsp;poured &lt;= 10<sup>9</sup></code></li>
72+
73+
<li><code>0 &lt;= query_glass &lt;= query_row&nbsp;&lt; 100</code></li>
74+
5975
</ul>
6076

6177
<!-- description:end -->

solution/0800-0899/0819.Most Common Word/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ tags:
2323

2424
<p><code>paragraph</code> 中的单词 <strong>不区分大小写</strong> ,答案应以 <strong>小写 </strong>形式返回。</p>
2525

26+
<p><b>注意</b>&nbsp;单词不包含标点符号。</p>
27+
2628
<p>&nbsp;</p>
2729

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

solution/1100-1199/1108.Defanging an IP Address/README_EN.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,29 @@ tags:
2323
<p>A <em>defanged&nbsp;IP address</em>&nbsp;replaces every period <code>&quot;.&quot;</code> with <code>&quot;[.]&quot;</code>.</p>
2424

2525
<p>&nbsp;</p>
26+
2627
<p><strong class="example">Example 1:</strong></p>
28+
2729
<pre><strong>Input:</strong> address = "1.1.1.1"
30+
2831
<strong>Output:</strong> "1[.]1[.]1[.]1"
32+
2933
</pre><p><strong class="example">Example 2:</strong></p>
34+
3035
<pre><strong>Input:</strong> address = "255.100.50.0"
36+
3137
<strong>Output:</strong> "255[.]100[.]50[.]0"
38+
3239
</pre>
40+
3341
<p>&nbsp;</p>
42+
3443
<p><strong>Constraints:</strong></p>
3544

3645
<ul>
37-
<li>The given <code>address</code> is a valid IPv4 address.</li>
46+
47+
<li>The given <code>address</code> is a valid IPv4 address.</li>
48+
3849
</ul>
3950

4051
<!-- description:end -->

solution/1100-1199/1111.Maximum Nesting Depth of Two Valid Parentheses Strings/README_EN.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,25 @@ tags:
2222
<p>A string is a <em>valid parentheses string</em>&nbsp;(denoted VPS) if and only if it consists of <code>&quot;(&quot;</code> and <code>&quot;)&quot;</code> characters only, and:</p>
2323

2424
<ul>
25-
<li>It is the empty string, or</li>
26-
<li>It can be written as&nbsp;<code>AB</code>&nbsp;(<code>A</code>&nbsp;concatenated with&nbsp;<code>B</code>), where&nbsp;<code>A</code>&nbsp;and&nbsp;<code>B</code>&nbsp;are VPS&#39;s, or</li>
27-
<li>It can be written as&nbsp;<code>(A)</code>, where&nbsp;<code>A</code>&nbsp;is a VPS.</li>
25+
26+
<li>It is the empty string, or</li>
27+
28+
<li>It can be written as&nbsp;<code>AB</code>&nbsp;(<code>A</code>&nbsp;concatenated with&nbsp;<code>B</code>), where&nbsp;<code>A</code>&nbsp;and&nbsp;<code>B</code>&nbsp;are VPS&#39;s, or</li>
29+
30+
<li>It can be written as&nbsp;<code>(A)</code>, where&nbsp;<code>A</code>&nbsp;is a VPS.</li>
31+
2832
</ul>
2933

3034
<p>We can&nbsp;similarly define the <em>nesting depth</em> <code>depth(S)</code> of any VPS <code>S</code> as follows:</p>
3135

3236
<ul>
33-
<li><code>depth(&quot;&quot;) = 0</code></li>
34-
<li><code>depth(A + B) = max(depth(A), depth(B))</code>, where <code>A</code> and <code>B</code> are VPS&#39;s</li>
35-
<li><code>depth(&quot;(&quot; + A + &quot;)&quot;) = 1 + depth(A)</code>, where <code>A</code> is a VPS.</li>
37+
38+
<li><code>depth(&quot;&quot;) = 0</code></li>
39+
40+
<li><code>depth(A + B) = max(depth(A), depth(B))</code>, where <code>A</code> and <code>B</code> are VPS&#39;s</li>
41+
42+
<li><code>depth(&quot;(&quot; + A + &quot;)&quot;) = 1 + depth(A)</code>, where <code>A</code> is a VPS.</li>
43+
3644
</ul>
3745

3846
<p>For example,&nbsp; <code>&quot;&quot;</code>,&nbsp;<code>&quot;()()&quot;</code>, and&nbsp;<code>&quot;()(()())&quot;</code>&nbsp;are VPS&#39;s (with nesting depths 0, 1, and 2), and <code>&quot;)(&quot;</code> and <code>&quot;(()&quot;</code> are not VPS&#39;s.</p>

solution/1100-1199/1138.Alphabet Board Path/README_EN.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,49 @@ tags:
2828
<p>We may make the following moves:</p>
2929

3030
<ul>
31-
<li><code>&#39;U&#39;</code> moves our position up one row, if the position exists on the board;</li>
32-
<li><code>&#39;D&#39;</code> moves our position down one row, if the position exists on the board;</li>
33-
<li><code>&#39;L&#39;</code> moves our position left one column, if the position exists on the board;</li>
34-
<li><code>&#39;R&#39;</code> moves our position right one column, if the position exists on the board;</li>
35-
<li><code>&#39;!&#39;</code>&nbsp;adds the character <code>board[r][c]</code> at our current position <code>(r, c)</code>&nbsp;to the&nbsp;answer.</li>
31+
32+
<li><code>&#39;U&#39;</code> moves our position up one row, if the position exists on the board;</li>
33+
34+
<li><code>&#39;D&#39;</code> moves our position down one row, if the position exists on the board;</li>
35+
36+
<li><code>&#39;L&#39;</code> moves our position left one column, if the position exists on the board;</li>
37+
38+
<li><code>&#39;R&#39;</code> moves our position right one column, if the position exists on the board;</li>
39+
40+
<li><code>&#39;!&#39;</code>&nbsp;adds the character <code>board[r][c]</code> at our current position <code>(r, c)</code>&nbsp;to the&nbsp;answer.</li>
41+
3642
</ul>
3743

3844
<p>(Here, the only positions that exist on the board are positions with letters on them.)</p>
3945

4046
<p>Return a sequence of moves that makes our answer equal to <code>target</code>&nbsp;in the minimum number of moves.&nbsp; You may return any path that does so.</p>
4147

4248
<p>&nbsp;</p>
49+
4350
<p><strong class="example">Example 1:</strong></p>
51+
4452
<pre><strong>Input:</strong> target = "leet"
53+
4554
<strong>Output:</strong> "DDR!UURRR!!DDD!"
55+
4656
</pre><p><strong class="example">Example 2:</strong></p>
57+
4758
<pre><strong>Input:</strong> target = "code"
59+
4860
<strong>Output:</strong> "RR!DDRR!UUL!R!"
61+
4962
</pre>
63+
5064
<p>&nbsp;</p>
65+
5166
<p><strong>Constraints:</strong></p>
5267

5368
<ul>
54-
<li><code>1 &lt;= target.length &lt;= 100</code></li>
55-
<li><code>target</code> consists only of English lowercase letters.</li>
69+
70+
<li><code>1 &lt;= target.length &lt;= 100</code></li>
71+
72+
<li><code>target</code> consists only of English lowercase letters.</li>
73+
5674
</ul>
5775

5876
<!-- description:end -->

solution/1100-1199/1139.Largest 1-Bordered Square/README_EN.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,39 @@ tags:
2323
<p>Given a 2D <code>grid</code> of <code>0</code>s and <code>1</code>s, return the number of elements in&nbsp;the largest <strong>square</strong>&nbsp;subgrid that has all <code>1</code>s on its <strong>border</strong>, or <code>0</code> if such a subgrid&nbsp;doesn&#39;t exist in the <code>grid</code>.</p>
2424

2525
<p>&nbsp;</p>
26+
2627
<p><strong class="example">Example 1:</strong></p>
2728

2829
<pre>
30+
2931
<strong>Input:</strong> grid = [[1,1,1],[1,0,1],[1,1,1]]
32+
3033
<strong>Output:</strong> 9
34+
3135
</pre>
3236

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

3539
<pre>
40+
3641
<strong>Input:</strong> grid = [[1,1,0,0]]
42+
3743
<strong>Output:</strong> 1
44+
3845
</pre>
3946

4047
<p>&nbsp;</p>
48+
4149
<p><strong>Constraints:</strong></p>
4250

4351
<ul>
44-
<li><code>1 &lt;= grid.length &lt;= 100</code></li>
45-
<li><code>1 &lt;= grid[0].length &lt;= 100</code></li>
46-
<li><code>grid[i][j]</code> is <code>0</code> or <code>1</code></li>
52+
53+
<li><code>1 &lt;= grid.length &lt;= 100</code></li>
54+
55+
<li><code>1 &lt;= grid[0].length &lt;= 100</code></li>
56+
57+
<li><code>grid[i][j]</code> is <code>0</code> or <code>1</code></li>
58+
4759
</ul>
4860

4961
<!-- description:end -->

solution/1100-1199/1160.Find Words That Can Be Formed by Characters/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ tags:
2121

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

24-
<p>给你一份『词汇表』(字符串数组)&nbsp;<code>words</code>&nbsp;和一张『字母表』(字符串)&nbsp;<code>chars</code>。</p>
24+
<p>给定一个字符串数组&nbsp;<code>words</code>&nbsp;和一个字符串 <code>chars</code>。</p>
2525

26-
<p>假如你可以用&nbsp;<code>chars</code>&nbsp;中的『字母』(字符)拼写出 <code>words</code>&nbsp;中的某个『单词』(字符串),那么我们就认为你掌握了这个单词。</p>
26+
<p>如果字符串可以由 <code>chars</code> 中的字符组成(每个字符在 <strong>每个</strong>&nbsp;<code>words</code> 中只能使用一次),则认为它是好的。</p>
2727

28-
<p>注意:每次拼写(指拼写词汇表中的一个单词)时,<code>chars</code> 中的每个字母都只能用一次。</p>
29-
30-
<p>返回词汇表&nbsp;<code>words</code>&nbsp;中你掌握的所有单词的 <strong>长度之和</strong>。</p>
28+
<p>返回&nbsp;<code>words</code>&nbsp;中所有好的字符串的长度之和。</p>
3129

3230
<p>&nbsp;</p>
3331

@@ -56,7 +54,7 @@ tags:
5654
<ul>
5755
<li><code>1 &lt;= words.length &lt;= 1000</code></li>
5856
<li><code>1 &lt;= words[i].length, chars.length&nbsp;&lt;= 100</code></li>
59-
<li>所有字符串中都仅包含小写英文字母</li>
57+
<li><code>words[i]</code>&nbsp;和&nbsp;<code>chars</code> 中都仅包含小写英文字母</li>
6058
</ul>
6159

6260
<!-- description:end -->

solution/1100-1199/1184.Distance Between Bus Stops/README_EN.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ tags:
2525
<p>Return the shortest distance between the given&nbsp;<code>start</code>&nbsp;and <code>destination</code>&nbsp;stops.</p>
2626

2727
<p>&nbsp;</p>
28+
2829
<p><strong class="example">Example 1:</strong></p>
2930

3031
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1100-1199/1184.Distance%20Between%20Bus%20Stops/images/untitled-diagram-1.jpg" style="width: 388px; height: 240px;" /></p>
3132

3233
<pre>
34+
3335
<strong>Input:</strong> distance = [1,2,3,4], start = 0, destination = 1
36+
3437
<strong>Output:</strong> 1
38+
3539
<strong>Explanation:</strong> Distance between 0 and 1 is 1 or 9, minimum is 1.</pre>
3640

3741
<p>&nbsp;</p>
@@ -41,9 +45,13 @@ tags:
4145
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1100-1199/1184.Distance%20Between%20Bus%20Stops/images/untitled-diagram-1-1.jpg" style="width: 388px; height: 240px;" /></p>
4246

4347
<pre>
48+
4449
<strong>Input:</strong> distance = [1,2,3,4], start = 0, destination = 2
50+
4551
<strong>Output:</strong> 3
52+
4653
<strong>Explanation:</strong> Distance between 0 and 2 is 3 or 7, minimum is 3.
54+
4755
</pre>
4856

4957
<p>&nbsp;</p>
@@ -53,19 +61,29 @@ tags:
5361
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1100-1199/1184.Distance%20Between%20Bus%20Stops/images/untitled-diagram-1-2.jpg" style="width: 388px; height: 240px;" /></p>
5462

5563
<pre>
64+
5665
<strong>Input:</strong> distance = [1,2,3,4], start = 0, destination = 3
66+
5767
<strong>Output:</strong> 4
68+
5869
<strong>Explanation:</strong> Distance between 0 and 3 is 6 or 4, minimum is 4.
70+
5971
</pre>
6072

6173
<p>&nbsp;</p>
74+
6275
<p><strong>Constraints:</strong></p>
6376

6477
<ul>
65-
<li><code>1 &lt;= n&nbsp;&lt;= 10^4</code></li>
66-
<li><code>distance.length == n</code></li>
67-
<li><code>0 &lt;= start, destination &lt; n</code></li>
68-
<li><code>0 &lt;= distance[i] &lt;= 10^4</code></li>
78+
79+
<li><code>1 &lt;= n&nbsp;&lt;= 10^4</code></li>
80+
81+
<li><code>distance.length == n</code></li>
82+
83+
<li><code>0 &lt;= start, destination &lt; n</code></li>
84+
85+
<li><code>0 &lt;= distance[i] &lt;= 10^4</code></li>
86+
6987
</ul>
7088

7189
<!-- description:end -->

0 commit comments

Comments
 (0)