Skip to content

Commit 3e4f595

Browse files
authored
feat: add new lc problems (#4251)
1 parent 9d3ff3f commit 3e4f595

File tree

155 files changed

+3108
-322
lines changed

Some content is hidden

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

155 files changed

+3108
-322
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>分割成一些 <span data-keyword="substring-nonempty">子串</span>,使每个子串都是 <strong><span data-keyword="palindrome-string">回文串</span></strong> 。返回 <code>s</code> 所有可能的分割方案。</p>
21+
<p>给你一个字符串 <code>s</code>,请你将<em> </em><code>s</code><em> </em>分割成一些子串,使每个子串都是 <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,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/0200-0299/0278.First Bad Version/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ tags:
3030
<strong>输入:</strong>n = 5, bad = 4
3131
<strong>输出:</strong>4
3232
<strong>解释:</strong>
33-
<code>调用 isBadVersion(3) -&gt; false
34-
调用 isBadVersion(5)&nbsp;-&gt; true
33+
<code>调用 isBadVersion(3) -&gt; false
34+
调用 isBadVersion(5)&nbsp;-&gt; true
3535
调用 isBadVersion(4)&nbsp;-&gt; true</code>
3636
<code>所以,4 是第一个错误的版本。</code>
3737
</pre>

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

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

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

23-
<p>&nbsp;</p>
23+
<p> </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><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>
39+
<p> </p>
4740

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

5043
<ul>
51-
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
44+
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
5245
<li><code>nums[i]</code> 不是 <code>0</code> 就是 <code>1</code></li>
5346
</ul>
5447

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

-8
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ 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-
4840
<p>&nbsp;</p>
4941
<p><strong>Constraints:</strong></p>
5042

solution/0700-0799/0766.Toeplitz Matrix/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ tags:
2929
<strong>输入:</strong>matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]
3030
<strong>输出:</strong>true
3131
<strong>解释:</strong>
32-
在上述矩阵中, 其对角线为:
33-
"[9]", "[5, 5]", "[1, 1, 1]", "[2, 2, 2]", "[3, 3]", "[4]"。
32+
在上述矩阵中, 其对角线为:
33+
"[9]", "[5, 5]", "[1, 1, 1]", "[2, 2, 2]", "[3, 3]", "[4]"。
3434
各条对角线上的所有元素均相同, 因此答案是 True 。
3535
</pre>
3636

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

+18-2
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/1100-1199/1108.Defanging an IP Address/README_EN.md

+12-1
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

+14-6
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

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

+15-3
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 -->

0 commit comments

Comments
 (0)