Skip to content

Commit 9649470

Browse files
committed
feat: update lc problems
1 parent 454c030 commit 9649470

File tree

29 files changed

+323
-349
lines changed

29 files changed

+323
-349
lines changed

solution/0000-0099/0015.3Sum/README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,43 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>给你一个包含 <code>n</code> 个整数的数组&nbsp;<code>nums</code>,判断&nbsp;<code>nums</code>&nbsp;中是否存在三个元素 <em>a,b,c ,</em>使得&nbsp;<em>a + b + c = </em>0 ?请你找出所有和为 <code>0</code> 且不重复的三元组。</p>
9+
<p>给你一个整数数组 <code>nums</code> ,判断是否存在三元组 <code>[nums[i], nums[j], nums[k]]</code> 满足 <code>i != j</code>、<code>i != k</code> 且 <code>j != k</code> ,同时还满足 <code>nums[i] + nums[j] + nums[k] == 0</code> 。请</p>
10+
11+
<p>你返回所有和为 <code>0</code> 且不重复的三元组。</p>
1012

1113
<p><strong>注意:</strong>答案中不可以包含重复的三元组。</p>
1214

1315
<p>&nbsp;</p>
1416

17+
<p>&nbsp;</p>
18+
1519
<p><strong>示例 1:</strong></p>
1620

1721
<pre>
1822
<strong>输入:</strong>nums = [-1,0,1,2,-1,-4]
1923
<strong>输出:</strong>[[-1,-1,2],[-1,0,1]]
24+
<strong>解释:</strong>
25+
nums[0] + nums[1] + nums[2] = (-1) + 0 + 1 = 0 。
26+
nums[1] + nums[2] + nums[4] = 0 + 1 + (-1) = 0 。
27+
nums[0] + nums[3] + nums[4] = (-1) + 2 + (-1) = 0 。
28+
不同的三元组是 [-1,0,1] 和 [-1,-1,2] 。
29+
注意,输出的顺序和三元组的顺序并不重要。
2030
</pre>
2131

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

2434
<pre>
2535
<strong>输入:</strong>nums = [0,1,1]
2636
<strong>输出:</strong>[]
37+
<strong>解释:</strong>唯一可能的三元组和不为 0 。
2738
</pre>
2839

2940
<p><strong>示例 3:</strong></p>
3041

3142
<pre>
3243
<strong>输入:</strong>nums = [0,0,0]
3344
<strong>输出:</strong>[[0,0,0]]
45+
<strong>解释:</strong>唯一可能的三元组和为 0 。
3446
</pre>
3547

3648
<p>&nbsp;</p>

solution/0000-0099/0020.Valid Parentheses/README.md

+7-19
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>给定一个只包括 <code>'('</code>,<code>')'</code>,<code>'{'</code>,<code>'}'</code>,<code>'['</code>,<code>']'</code> 的字符串 <code>s</code> ,判断字符串是否有效。</p>
9+
<p>给定一个只包括 <code>'('</code>,<code>')'</code>,<code>'{'</code>,<code>'}'</code>,<code>'['</code>,<code>']'</code>&nbsp;的字符串 <code>s</code> ,判断字符串是否有效。</p>
1010

1111
<p>有效字符串需满足:</p>
1212

1313
<ol>
1414
<li>左括号必须用相同类型的右括号闭合。</li>
1515
<li>左括号必须以正确的顺序闭合。</li>
16+
<li>每个右括号都有一个对应的相同类型的左括号。</li>
1617
</ol>
1718

18-
<p> </p>
19+
<p>&nbsp;</p>
1920

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

@@ -24,39 +25,26 @@
2425
<strong>输出:</strong>true
2526
</pre>
2627

27-
<p><strong>示例 2:</strong></p>
28+
<p><strong>示例&nbsp;2:</strong></p>
2829

2930
<pre>
3031
<strong>输入:</strong>s = "()[]{}"
3132
<strong>输出:</strong>true
3233
</pre>
3334

34-
<p><strong>示例 3:</strong></p>
35+
<p><strong>示例&nbsp;3:</strong></p>
3536

3637
<pre>
3738
<strong>输入:</strong>s = "(]"
3839
<strong>输出:</strong>false
3940
</pre>
4041

41-
<p><strong>示例 4:</strong></p>
42-
43-
<pre>
44-
<strong>输入:</strong>s = "([)]"
45-
<strong>输出:</strong>false
46-
</pre>
47-
48-
<p><strong>示例 5:</strong></p>
49-
50-
<pre>
51-
<strong>输入:</strong>s = "{[]}"
52-
<strong>输出:</strong>true</pre>
53-
54-
<p> </p>
42+
<p>&nbsp;</p>
5543

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

5846
<ul>
59-
<li><code>1 <= s.length <= 10<sup>4</sup></code></li>
47+
<li><code>1 &lt;= s.length &lt;= 10<sup>4</sup></code></li>
6048
<li><code>s</code> 仅由括号 <code>'()[]{}'</code> 组成</li>
6149
</ul>
6250

solution/0000-0099/0030.Substring with Concatenation of All Words/README.md

+25-13
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,58 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>给定一个字符串 <code>s</code><strong> </strong>和一些 <strong>长度相同</strong> 的单词 <code>words</code><strong> 。</strong>找出 <code>s</code><strong> </strong>中恰好可以由 <code>words</code><strong> </strong>中所有单词串联形成的子串的起始位置。</p>
9+
<p>给定一个字符串&nbsp;<code>s</code><strong>&nbsp;</strong>和一个字符串数组&nbsp;<code>words</code><strong>。</strong>&nbsp;<code>words</code>&nbsp;中所有字符串 <strong>长度相同</strong>。</p>
1010

11-
<p>注意子串要与 <code>words</code><strong> </strong>中的单词完全匹配,<strong>中间不能有其他字符 </strong>,但不需要考虑 <code>words</code><strong> </strong>中单词串联的顺序。</p>
11+
<p>&nbsp;<code>s</code><strong>&nbsp;</strong>中的 <strong>串联子串</strong> 是指一个包含&nbsp;&nbsp;<code>words</code>&nbsp;中所有字符串以任意顺序排列连接起来的子串。</p>
1212

13-
<p> </p>
13+
<ul>
14+
<li>例如,如果&nbsp;<code>words = ["ab","cd","ef"]</code>, 那么&nbsp;<code>"abcdef"</code>,&nbsp;<code>"abefcd"</code>,<code>"cdabef"</code>,&nbsp;<code>"cdefab"</code>,<code>"efabcd"</code>, 和&nbsp;<code>"efcdab"</code> 都是串联子串。&nbsp;<code>"acdbef"</code> 不是串联子串,因为他不是任何&nbsp;<code>words</code>&nbsp;排列的连接。</li>
15+
</ul>
16+
17+
<p>返回所有串联字串在&nbsp;<code>s</code><strong>&nbsp;</strong>中的开始索引。你可以以 <strong>任意顺序</strong> 返回答案。</p>
18+
19+
<p>&nbsp;</p>
1420

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

1723
<pre>
1824
<strong>输入:</strong>s = "barfoothefoobarman", words = ["foo","bar"]
1925
<strong>输出:</strong><code>[0,9]</code>
20-
<strong>解释:</strong>
21-
从索引 0 和 9 开始的子串分别是 "barfoo" 和 "foobar" 。
22-
输出的顺序不重要, [9,0] 也是有效答案。
26+
<strong>解释:</strong>因为 words.length == 2 同时 words[i].length == 3,连接的子字符串的长度必须为 6。
27+
子串 "barfoo" 开始位置是 0。它是 words 中以 ["bar","foo"] 顺序排列的连接。
28+
子串 "foobar" 开始位置是 9。它是 words 中以 ["foo","bar"] 顺序排列的连接。
29+
输出顺序无关紧要。返回 [9,0] 也是可以的。
2330
</pre>
2431

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

2734
<pre>
2835
<strong>输入:</strong>s = "wordgoodgoodgoodbestword", words = ["word","good","best","word"]
2936
<code><strong>输出:</strong>[]</code>
37+
<strong>解释:</strong>因为<strong> </strong>words.length == 4 并且 words[i].length == 4,所以串联子串的长度必须为 16。
38+
s 中没有子串长度为 16 并且等于 words 的任何顺序排列的连接。
39+
所以我们返回一个空数组。
3040
</pre>
3141

3242
<p><strong>示例 3:</strong></p>
3343

3444
<pre>
3545
<strong>输入:</strong>s = "barfoofoobarthefoobarman", words = ["bar","foo","the"]
3646
<strong>输出:</strong>[6,9,12]
37-
</pre>
47+
<strong>解释:</strong>因为 words.length == 3 并且 words[i].length == 3,所以串联子串的长度必须为 9。
48+
子串 "foobarthe" 开始位置是 6。它是 words 中以 ["foo","bar","the"] 顺序排列的连接。
49+
子串 "barthefoo" 开始位置是 9。它是 words 中以 ["bar","the","foo"] 顺序排列的连接。
50+
子串 "thefoobar" 开始位置是 12。它是 words 中以 ["the","foo","bar"] 顺序排列的连接。</pre>
3851

39-
<p> </p>
52+
<p>&nbsp;</p>
4053

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

4356
<ul>
44-
<li><code>1 <= s.length <= 10<sup>4</sup></code></li>
45-
<li><code>s</code> 由小写英文字母组成</li>
46-
<li><code>1 <= words.length <= 5000</code></li>
47-
<li><code>1 <= words[i].length <= 30</code></li>
48-
<li><code>words[i]</code> 由小写英文字母组成</li>
57+
<li><code>1 &lt;= s.length &lt;= 10<sup>4</sup></code></li>
58+
<li><code>1 &lt;= words.length &lt;= 5000</code></li>
59+
<li><code>1 &lt;= words[i].length &lt;= 30</code></li>
60+
<li><code>words[i]</code>&nbsp;和&nbsp;<code>s</code> 由小写英文字母组成</li>
4961
</ul>
5062

5163
## 解法

solution/0000-0099/0076.Minimum Window Substring/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Since the largest window of s only has one &#39;a&#39;, return empty string.
4747
</ul>
4848

4949
<p>&nbsp;</p>
50-
<strong>Follow up:</strong> Could you find an algorithm that runs in <code>O(m + n)</code> time?
50+
<p><strong>Follow up:</strong> Could you find an algorithm that runs in <code>O(m + n)</code> time?</p>
5151

5252
## Solutions
5353

solution/0100-0199/0126.Word Ladder II/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<li><code>beginWord</code>, <code>endWord</code>, and <code>wordList[i]</code> consist of lowercase English letters.</li>
4545
<li><code>beginWord != endWord</code></li>
4646
<li>All the words in <code>wordList</code> are <strong>unique</strong>.</li>
47+
<li>The <strong>sum</strong> of all shortest transformation sequences does not exceed <code>10<sup>5</sup></code>.</li>
4748
</ul>
4849

4950
## Solutions

solution/0100-0199/0160.Intersection of Two Linked Lists/README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<p>图示两个链表在节点 <code>c1</code> 开始相交<strong>:</strong></p>
1212

13-
<p><a href="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0160.Intersection%20of%20Two%20Linked%20Lists/images/160_statement.png" target="_blank"><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0160.Intersection%20of%20Two%20Linked%20Lists/images/160_statement.png" style="height: 130px; width: 400px;" /></a></p>
13+
<p><a href="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0160.Intersection%20of%20Two%20Linked%20Lists/images/160_statement.png" target="_blank"><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0160.Intersection%20of%20Two%20Linked%20Lists/images/160_statement.png" style="height:130px; width:400px" /></a></p>
1414

1515
<p>题目数据 <strong>保证</strong> 整个链式结构中不存在环。</p>
1616

@@ -34,19 +34,22 @@
3434

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

37-
<p><a href="https://assets.leetcode.com/uploads/2018/12/13/160_example_1.png" target="_blank"><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0160.Intersection%20of%20Two%20Linked%20Lists/images/160_example_1_1.png" style="height: 130px; width: 400px;" /></a></p>
37+
<p><a href="https://assets.leetcode.com/uploads/2018/12/13/160_example_1.png" target="_blank"><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0160.Intersection%20of%20Two%20Linked%20Lists/images/160_example_1_1.png" style="height:130px; width:400px" /></a></p>
3838

3939
<pre>
4040
<strong>输入:</strong>intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3
4141
<strong>输出:</strong>Intersected at '8'
4242
<strong>解释:</strong>相交节点的值为 8 (注意,如果两个链表相交则不能为 0)。
4343
从各自的表头开始算起,链表 A 为 [4,1,8,4,5],链表 B 为 [5,6,1,8,4,5]。
4444
在 A 中,相交节点前有 2 个节点;在 B 中,相交节点前有 3 个节点。
45+
— 请注意相交节点的值不为 1,因为在链表 A 和链表 B 之中值为 1 的节点 (A 中第二个节点和 B 中第三个节点) 是不同的节点。换句话说,它们在内存中指向两个不同的位置,而链表 A 和链表 B 中值为 8 的节点 (A 中<font size="1">第三个</font>节点,B 中第四个节点) 在内存中指向相同的位置。
4546
</pre>
4647

48+
<p>&nbsp;</p>
49+
4750
<p><strong>示例&nbsp;2:</strong></p>
4851

49-
<p><a href="https://assets.leetcode.com/uploads/2018/12/13/160_example_2.png" target="_blank"><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0160.Intersection%20of%20Two%20Linked%20Lists/images/160_example_2.png" style="height: 136px; width: 350px;" /></a></p>
52+
<p><a href="https://assets.leetcode.com/uploads/2018/12/13/160_example_2.png" target="_blank"><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0160.Intersection%20of%20Two%20Linked%20Lists/images/160_example_2.png" style="height:136px; width:350px" /></a></p>
5053

5154
<pre>
5255
<strong>输入:</strong>intersectVal&nbsp;= 2, listA = [1,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1
@@ -58,7 +61,7 @@
5861

5962
<p><strong>示例&nbsp;3:</strong></p>
6063

61-
<p><a href="https://assets.leetcode.com/uploads/2018/12/13/160_example_3.png" target="_blank"><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0160.Intersection%20of%20Two%20Linked%20Lists/images/160_example_3.png" style="height: 126px; width: 200px;" /></a></p>
64+
<p><a href="https://assets.leetcode.com/uploads/2018/12/13/160_example_3.png" target="_blank"><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0160.Intersection%20of%20Two%20Linked%20Lists/images/160_example_3.png" style="height:126px; width:200px" /></a></p>
6265

6366
<pre>
6467
<strong>输入:</strong>intersectVal = 0, listA = [2,6,4], listB = [1,5], skipA = 3, skipB = 2

solution/0200-0299/0237.Delete Node in a Linked List/README.md

+23-4
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,41 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>请编写一个函数,用于 <strong>删除单链表中某个特定节点</strong> 。在设计函数时需要注意,你无法访问链表的头节点&nbsp;<code>head</code> ,只能直接访问 <strong>要被删除的节点</strong> 。</p>
9+
<p>有一个单链表的&nbsp;<code>head</code>,我们想删除它其中的一个节点&nbsp;<code>node</code>。</p>
1010

11-
<p>题目数据保证需要删除的节点 <strong>不是末尾节点</strong> 。</p>
11+
<p>给你一个需要删除的节点&nbsp;<code>node</code>&nbsp;。你将&nbsp;<strong>无法访问</strong>&nbsp;第一个节点&nbsp;&nbsp;<code>head</code>。</p>
12+
13+
<p>链表的所有值都是 <b>唯一的</b>,并且保证给定的节点&nbsp;<code>node</code>&nbsp;不是链表中的最后一个节点。</p>
14+
15+
<p>删除给定的节点。注意,删除节点并不是指从内存中删除它。这里的意思是:</p>
16+
17+
<ul>
18+
<li>给定节点的值不应该存在于链表中。</li>
19+
<li>链表中的节点数应该减少 1。</li>
20+
<li><code>node</code>&nbsp;前面的所有值顺序相同。</li>
21+
<li><code>node</code>&nbsp;后面的所有值顺序相同。</li>
22+
</ul>
23+
24+
<p><strong>自定义测试:</strong></p>
25+
26+
<ul>
27+
<li>对于输入,你应该提供整个链表&nbsp;<code>head</code>&nbsp;和要给出的节点&nbsp;<code>node</code>。<code>node</code>&nbsp;不应该是链表的最后一个节点,而应该是链表中的一个实际节点。</li>
28+
<li>我们将构建链表,并将节点传递给你的函数。</li>
29+
<li>输出将是调用你函数后的整个链表。</li>
30+
</ul>
1231

1332
<p>&nbsp;</p>
1433

1534
<p><strong>示例 1:</strong></p>
16-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0237.Delete%20Node%20in%20a%20Linked%20List/images/node1.jpg" style="height: 215px; width: 300px;" />
35+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0237.Delete%20Node%20in%20a%20Linked%20List/images/node1.jpg" style="height: 286px; width: 400px;" />
1736
<pre>
1837
<strong>输入:</strong>head = [4,5,1,9], node = 5
1938
<strong>输出:</strong>[4,1,9]
2039
<strong>解释:</strong>指定链表中值为&nbsp;5&nbsp;的第二个节点,那么在调用了你的函数之后,该链表应变为 4 -&gt; 1 -&gt; 9
2140
</pre>
2241

2342
<p><strong>示例 2:</strong></p>
24-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0237.Delete%20Node%20in%20a%20Linked%20List/images/node2.jpg" style="height: 236px; width: 300px;" />
43+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0237.Delete%20Node%20in%20a%20Linked%20List/images/node2.jpg" style="height: 315px; width: 400px;" />
2544
<pre>
2645
<strong>输入:</strong>head = [4,5,1,9], node = 1
2746
<strong>输出:</strong>[4,5,9]

solution/0200-0299/0237.Delete Node in a Linked List/README_EN.md

+24-5
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,40 @@
44

55
## Description
66

7-
<p>Write a function to <strong>delete a node</strong> in a singly-linked list. You will <strong>not</strong> be given access to the <code>head</code> of the list, instead you will be given access to <strong>the node to be deleted</strong> directly.</p>
7+
<p>There is a singly-linked list <code>head</code> and we want to delete a node <code>node</code> in it.</p>
88

9-
<p>It is <strong>guaranteed</strong> that the node to be deleted is <strong>not a tail node</strong> in the list.</p>
9+
<p>You are given the node to be deleted <code>node</code>. You will <strong>not be given access</strong> to the first node of <code>head</code>.</p>
10+
11+
<p>All the values of the linked list are <strong>unique</strong>, and it is guaranteed that the given node <code>node</code> is not the last node in the linked list.</p>
12+
13+
<p>Delete the given node. Note that by deleting the node, we do not mean removing it from memory. We mean:</p>
14+
15+
<ul>
16+
<li>The value of the given node should not exist in the linked list.</li>
17+
<li>The number of nodes in the linked list should decrease by one.</li>
18+
<li>All the values before <code>node</code> should be in the same order.</li>
19+
<li>All the values after <code>node</code> should be in the same order.</li>
20+
</ul>
21+
22+
<p><strong>Custom testing:</strong></p>
23+
24+
<ul>
25+
<li>For the input, you should provide the entire linked list <code>head</code> and the node to be given <code>node</code>. <code>node</code> should not be the last node of the list and should be an actual node in the list.</li>
26+
<li>We will build the linked list and pass the node to your function.</li>
27+
<li>The output will be the entire list after calling your function.</li>
28+
</ul>
1029

1130
<p>&nbsp;</p>
1231
<p><strong>Example 1:</strong></p>
13-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0237.Delete%20Node%20in%20a%20Linked%20List/images/node1.jpg" style="width: 300px; height: 215px;" />
32+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0237.Delete%20Node%20in%20a%20Linked%20List/images/node1.jpg" style="width: 400px; height: 286px;" />
1433
<pre>
1534
<strong>Input:</strong> head = [4,5,1,9], node = 5
1635
<strong>Output:</strong> [4,1,9]
1736
<strong>Explanation: </strong>You are given the second node with value 5, the linked list should become 4 -&gt; 1 -&gt; 9 after calling your function.
1837
</pre>
1938

2039
<p><strong>Example 2:</strong></p>
21-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0237.Delete%20Node%20in%20a%20Linked%20List/images/node2.jpg" style="width: 300px; height: 236px;" />
40+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0237.Delete%20Node%20in%20a%20Linked%20List/images/node2.jpg" style="width: 400px; height: 315px;" />
2241
<pre>
2342
<strong>Input:</strong> head = [4,5,1,9], node = 1
2443
<strong>Output:</strong> [4,5,9]
@@ -32,7 +51,7 @@
3251
<li>The number of the nodes in the given list is in the range <code>[2, 1000]</code>.</li>
3352
<li><code>-1000 &lt;= Node.val &lt;= 1000</code></li>
3453
<li>The value of each node in the list is <strong>unique</strong>.</li>
35-
<li>The <code>node</code> to be deleted is <strong>in the list</strong> and is <strong>not a tail</strong> node</li>
54+
<li>The <code>node</code> to be deleted is <strong>in the list</strong> and is <strong>not a tail</strong> node.</li>
3655
</ul>
3756

3857
## Solutions

solution/0300-0399/0336.Palindrome Pairs/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<strong>输出:</strong>[[0,1],[1,0]]
3333
</pre>
3434

35+
36+
3537
<p><strong>提示:</strong></p>
3638

3739
<ul>

0 commit comments

Comments
 (0)