Skip to content

Commit b8792d6

Browse files
authored
feat: update lc problems (#4135)
1 parent a6cd01a commit b8792d6

File tree

72 files changed

+14469
-15202
lines changed

Some content is hidden

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

72 files changed

+14469
-15202
lines changed

solution/0100-0199/0131.Palindrome Partitioning/README.md

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

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

21-
<p>给你一个字符串 <code>s</code>,请你将<em> </em><code>s</code><em> </em>分割成一些子串,使每个子串都是 <strong><span data-keyword="palindrome-string">回文串</span></strong> 。返回 <code>s</code> 所有可能的分割方案。</p>
21+
<p>给你一个字符串 <code>s</code>,请你将<em> </em><code>s</code><em> </em>分割成一些 <span data-keyword="substring-nonempty">子串</span>,使每个子串都是 <strong><span data-keyword="palindrome-string">回文串</span></strong> 。返回 <code>s</code> 所有可能的分割方案。</p>
2222

2323
<p>&nbsp;</p>
2424

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

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

2525
<pre>
26-
2726
Line 1
28-
2927
Line 2
30-
3128
Line 3
32-
3329
Line 4
34-
3530
Line 5
36-
3731
Line 6
38-
3932
Line 7
40-
4133
Line 8
42-
4334
Line 9
44-
4535
Line 10
46-
4736
</pre>
4837

4938
<p>Your script should output the tenth line, which is:</p>
5039

5140
<pre>
52-
5341
Line 10
54-
5542
</pre>
5643

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

6348
<!-- description:end -->

solution/0500-0599/0525.Contiguous Array/README.md

+18-11
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,35 @@ tags:
2020

2121
<p>给定一个二进制数组 <code>nums</code> , 找到含有相同数量的 <code>0</code> 和 <code>1</code> 的最长连续子数组,并返回该子数组的长度。</p>
2222

23-
<p> </p>
23+
<p>&nbsp;</p>
2424

25-
<p><strong>示例 1:</strong></p>
25+
<p><strong>示例 1</strong></p>
2626

2727
<pre>
28-
<strong>输入:</strong> nums = [0,1]
29-
<strong>输出:</strong> 2
30-
<strong>说明:</strong> [0, 1] 是具有相同数量 0 和 1 的最长连续子数组。</pre>
28+
<strong>输入</strong>nums = [0,1]
29+
<strong>输出</strong>2
30+
<strong>说明</strong>[0, 1] 是具有相同数量 0 和 1 的最长连续子数组。</pre>
3131

32-
<p><strong>示例 2:</strong></p>
32+
<p><strong>示例 2</strong></p>
3333

3434
<pre>
35-
<strong>输入:</strong> nums = [0,1,0]
36-
<strong>输出:</strong> 2
37-
<strong>说明:</strong> [0, 1] (或 [1, 0]) 是具有相同数量0和1的最长连续子数组。</pre>
35+
<strong>输入</strong>nums = [0,1,0]
36+
<strong>输出</strong>2
37+
<strong>说明</strong>[0, 1] (或 [1, 0]) 是具有相同数量 0 和 1 的最长连续子数组。</pre>
3838

39-
<p> </p>
39+
<p><strong>示例 3:</strong></p>
40+
41+
<pre>
42+
<b>输入:</b>nums = [0,1,1,1,1,1,0,0,0]
43+
<b>输出:</b>6
44+
<b>解释:</b>[1,1,1,0,0,0] 是具有相同数量 0 和 1 的最长连续子数组。</pre>
45+
46+
<p>&nbsp;</p>
4047

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

4350
<ul>
44-
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
51+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
4552
<li><code>nums[i]</code> 不是 <code>0</code> 就是 <code>1</code></li>
4653
</ul>
4754

solution/0500-0599/0525.Contiguous Array/README_EN.md

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ tags:
3737
<strong>Explanation:</strong> [0, 1] (or [1, 0]) is a longest contiguous subarray with equal number of 0 and 1.
3838
</pre>
3939

40+
<p><strong class="example">Example 3:</strong></p>
41+
42+
<pre>
43+
<strong>Input:</strong> nums = [0,1,1,1,1,1,0,0,0]
44+
<strong>Output:</strong> 6
45+
<strong>Explanation:</strong> [1,1,1,0,0,0] is the longest contiguous subarray with equal number of 0 and 1.
46+
</pre>
47+
4048
<p>&nbsp;</p>
4149
<p><strong>Constraints:</strong></p>
4250

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

+2-18
Original file line numberDiff line numberDiff line change
@@ -27,51 +27,35 @@ 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-
3130
<p><strong class="example">Example 1:</strong></p>
3231

3332
<pre>
34-
3533
<strong>Input:</strong> poured = 1, query_row = 1, query_glass = 1
36-
3734
<strong>Output:</strong> 0.00000
38-
3935
<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-
4136
</pre>
4237

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

4540
<pre>
46-
4741
<strong>Input:</strong> poured = 2, query_row = 1, query_glass = 1
48-
4942
<strong>Output:</strong> 0.50000
50-
5143
<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-
5344
</pre>
5445

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

5748
<pre>
58-
5949
<strong>Input:</strong> poured = 100000009, query_row = 33, query_glass = 17
60-
6150
<strong>Output:</strong> 1.00000
62-
6351
</pre>
6452

6553
<p>&nbsp;</p>
66-
6754
<p><strong>Constraints:</strong></p>
6855

6956
<ul>
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-
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>
7559
</ul>
7660

7761
<!-- description:end -->

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

+1-12
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,18 @@ 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-
2726
<p><strong class="example">Example 1:</strong></p>
28-
2927
<pre><strong>Input:</strong> address = "1.1.1.1"
30-
3128
<strong>Output:</strong> "1[.]1[.]1[.]1"
32-
3329
</pre><p><strong class="example">Example 2:</strong></p>
34-
3530
<pre><strong>Input:</strong> address = "255.100.50.0"
36-
3731
<strong>Output:</strong> "255[.]100[.]50[.]0"
38-
3932
</pre>
40-
4133
<p>&nbsp;</p>
42-
4334
<p><strong>Constraints:</strong></p>
4435

4536
<ul>
46-
47-
<li>The given <code>address</code> is a valid IPv4 address.</li>
48-
37+
<li>The given <code>address</code> is a valid IPv4 address.</li>
4938
</ul>
5039

5140
<!-- description:end -->

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

+6-14
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,17 @@ 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-
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-
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>
3228
</ul>
3329

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

3632
<ul>
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-
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>
4436
</ul>
4537

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

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

3030
<ul>
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-
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>
4236
</ul>
4337

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

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

4842
<p>&nbsp;</p>
49-
5043
<p><strong class="example">Example 1:</strong></p>
51-
5244
<pre><strong>Input:</strong> target = "leet"
53-
5445
<strong>Output:</strong> "DDR!UURRR!!DDD!"
55-
5646
</pre><p><strong class="example">Example 2:</strong></p>
57-
5847
<pre><strong>Input:</strong> target = "code"
59-
6048
<strong>Output:</strong> "RR!DDRR!UUL!R!"
61-
6249
</pre>
63-
6450
<p>&nbsp;</p>
65-
6651
<p><strong>Constraints:</strong></p>
6752

6853
<ul>
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-
54+
<li><code>1 &lt;= target.length &lt;= 100</code></li>
55+
<li><code>target</code> consists only of English lowercase letters.</li>
7456
</ul>
7557

7658
<!-- description:end -->

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

+3-15
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,27 @@ 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-
2726
<p><strong class="example">Example 1:</strong></p>
2827

2928
<pre>
30-
3129
<strong>Input:</strong> grid = [[1,1,1],[1,0,1],[1,1,1]]
32-
3330
<strong>Output:</strong> 9
34-
3531
</pre>
3632

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

3935
<pre>
40-
4136
<strong>Input:</strong> grid = [[1,1,0,0]]
42-
4337
<strong>Output:</strong> 1
44-
4538
</pre>
4639

4740
<p>&nbsp;</p>
48-
4941
<p><strong>Constraints:</strong></p>
5042

5143
<ul>
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-
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>
5947
</ul>
6048

6149
<!-- description:end -->

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

+4-22
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,13 @@ 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-
2928
<p><strong class="example">Example 1:</strong></p>
3029

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

3332
<pre>
34-
3533
<strong>Input:</strong> distance = [1,2,3,4], start = 0, destination = 1
36-
3734
<strong>Output:</strong> 1
38-
3935
<strong>Explanation:</strong> Distance between 0 and 1 is 1 or 9, minimum is 1.</pre>
4036

4137
<p>&nbsp;</p>
@@ -45,13 +41,9 @@ tags:
4541
<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>
4642

4743
<pre>
48-
4944
<strong>Input:</strong> distance = [1,2,3,4], start = 0, destination = 2
50-
5145
<strong>Output:</strong> 3
52-
5346
<strong>Explanation:</strong> Distance between 0 and 2 is 3 or 7, minimum is 3.
54-
5547
</pre>
5648

5749
<p>&nbsp;</p>
@@ -61,29 +53,19 @@ tags:
6153
<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>
6254

6355
<pre>
64-
6556
<strong>Input:</strong> distance = [1,2,3,4], start = 0, destination = 3
66-
6757
<strong>Output:</strong> 4
68-
6958
<strong>Explanation:</strong> Distance between 0 and 3 is 6 or 4, minimum is 4.
70-
7159
</pre>
7260

7361
<p>&nbsp;</p>
74-
7562
<p><strong>Constraints:</strong></p>
7663

7764
<ul>
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-
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>
8769
</ul>
8870

8971
<!-- description:end -->

0 commit comments

Comments
 (0)