Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b4c857b

Browse files
committed
feat: update lc problems
1 parent 2ed53a3 commit b4c857b

File tree

40 files changed

+435
-388
lines changed

40 files changed

+435
-388
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

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

9-
<p>给你一个包含 <code>n</code> 个整数的数组<code>nums</code>,判断<code>nums</code>中是否存在三个元素 <em>a,b,c ,</em>使得<em>a + b + c = </em>0 ?请你找出所有和为 <code>0</code> 且不重复的三元组。</p>
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>
1010

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

13-
<p></p>
13+
<p>&nbsp;</p>
1414

1515
<p><strong>示例 1:</strong></p>
1616

@@ -22,24 +22,24 @@
2222
<p><strong>示例 2:</strong></p>
2323

2424
<pre>
25-
<strong>输入:</strong>nums = []
25+
<strong>输入:</strong>nums = [0,1,1]
2626
<strong>输出:</strong>[]
2727
</pre>
2828

2929
<p><strong>示例 3:</strong></p>
3030

3131
<pre>
32-
<strong>输入:</strong>nums = [0]
33-
<strong>输出:</strong>[]
32+
<strong>输入:</strong>nums = [0,0,0]
33+
<strong>输出:</strong>[[0,0,0]]
3434
</pre>
3535

36-
<p></p>
36+
<p>&nbsp;</p>
3737

3838
<p><strong>提示:</strong></p>
3939

4040
<ul>
41-
<li><code>0 <= nums.length <= 3000</code></li>
42-
<li><code>-10<sup>5</sup> <= nums[i] <= 10<sup>5</sup></code></li>
41+
<li><code>3 &lt;= nums.length &lt;= 3000</code></li>
42+
<li><code>-10<sup>5</sup> &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
4343
</ul>
4444

4545
## 解法

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,47 @@
44

55
## Description
66

7-
<p>You are given a string <code>s</code> and an array of strings <code>words</code> of <strong>the same length</strong>. Return&nbsp;all starting indices of substring(s) in <code>s</code>&nbsp;that is a concatenation of each word in <code>words</code> <strong>exactly once</strong>, <strong>in any order</strong>,&nbsp;and <strong>without any intervening characters</strong>.</p>
7+
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p>
88

9-
<p>You can return the answer in <strong>any order</strong>.</p>
9+
<p>A <strong>concatenated substring</strong> in <code>s</code> is a substring that contains all the strings of any permutation of <code>words</code> concatenated.</p>
10+
11+
<ul>
12+
<li>For example, if <code>words = [&quot;ab&quot;,&quot;cd&quot;,&quot;ef&quot;]</code>, then <code>&quot;abcdef&quot;</code>, <code>&quot;abefcd&quot;</code>, <code>&quot;cdabef&quot;</code>, <code>&quot;cdefab&quot;</code>, <code>&quot;efabcd&quot;</code>, and <code>&quot;efcdab&quot;</code> are all concatenated strings. <code>&quot;acdbef&quot;</code> is not a concatenated substring because it is not the concatenation of any permutation of <code>words</code>.</li>
13+
</ul>
14+
15+
<p>Return <em>the starting indices of all the concatenated substrings in </em><code>s</code>. You can return the answer in <strong>any order</strong>.</p>
1016

1117
<p>&nbsp;</p>
1218
<p><strong>Example 1:</strong></p>
1319

1420
<pre>
1521
<strong>Input:</strong> s = &quot;barfoothefoobarman&quot;, words = [&quot;foo&quot;,&quot;bar&quot;]
1622
<strong>Output:</strong> [0,9]
17-
<strong>Explanation:</strong> Substrings starting at index 0 and 9 are &quot;barfoo&quot; and &quot;foobar&quot; respectively.
18-
The output order does not matter, returning [9,0] is fine too.
23+
<strong>Explanation:</strong> Since words.length == 2 and words[i].length == 3, the concatenated substring has to be of length 6.
24+
The substring starting at 0 is &quot;barfoo&quot;. It is the concatenation of [&quot;bar&quot;,&quot;foo&quot;] which is a permutation of words.
25+
The substring starting at 9 is &quot;foobar&quot;. It is the concatenation of [&quot;foo&quot;,&quot;bar&quot;] which is a permutation of words.
26+
The output order does not matter. Returning [9,0] is fine too.
1927
</pre>
2028

2129
<p><strong>Example 2:</strong></p>
2230

2331
<pre>
2432
<strong>Input:</strong> s = &quot;wordgoodgoodgoodbestword&quot;, words = [&quot;word&quot;,&quot;good&quot;,&quot;best&quot;,&quot;word&quot;]
2533
<strong>Output:</strong> []
34+
<strong>Explanation:</strong> Since words.length == 4 and words[i].length == 4, the concatenated substring has to be of length 16.
35+
There is no substring of length 16 is s that is equal to the concatenation of any permutation of words.
36+
We return an empty array.
2637
</pre>
2738

2839
<p><strong>Example 3:</strong></p>
2940

3041
<pre>
3142
<strong>Input:</strong> s = &quot;barfoofoobarthefoobarman&quot;, words = [&quot;bar&quot;,&quot;foo&quot;,&quot;the&quot;]
3243
<strong>Output:</strong> [6,9,12]
44+
<strong>Explanation:</strong> Since words.length == 3 and words[i].length == 3, the concatenated substring has to be of length 9.
45+
The substring starting at 6 is &quot;foobarthe&quot;. It is the concatenation of [&quot;foo&quot;,&quot;bar&quot;,&quot;the&quot;] which is a permutation of words.
46+
The substring starting at 9 is &quot;barthefoo&quot;. It is the concatenation of [&quot;bar&quot;,&quot;the&quot;,&quot;foo&quot;] which is a permutation of words.
47+
The substring starting at 12 is &quot;thefoobar&quot;. It is the concatenation of [&quot;the&quot;,&quot;foo&quot;,&quot;bar&quot;] which is a permutation of words.
3348
</pre>
3449

3550
<p>&nbsp;</p>

‎solution/0000-0099/0041.First Missing Positive/README_EN.md‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,34 @@
1010

1111
<p>&nbsp;</p>
1212
<p><strong>Example 1:</strong></p>
13-
<pre><strong>Input:</strong> nums = [1,2,0]
13+
14+
<pre>
15+
<strong>Input:</strong> nums = [1,2,0]
1416
<strong>Output:</strong> 3
15-
</pre><p><strong>Example 2:</strong></p>
16-
<pre><strong>Input:</strong> nums = [3,4,-1,1]
17+
<strong>Explanation:</strong> The numbers in the range [1,2] are all in the array.
18+
</pre>
19+
20+
<p><strong>Example 2:</strong></p>
21+
22+
<pre>
23+
<strong>Input:</strong> nums = [3,4,-1,1]
1724
<strong>Output:</strong> 2
18-
</pre><p><strong>Example 3:</strong></p>
19-
<pre><strong>Input:</strong> nums = [7,8,9,11,12]
25+
<strong>Explanation:</strong> 1 is in the array but 2 is missing.
26+
</pre>
27+
28+
<p><strong>Example 3:</strong></p>
29+
30+
<pre>
31+
<strong>Input:</strong> nums = [7,8,9,11,12]
2032
<strong>Output:</strong> 1
33+
<strong>Explanation:</strong> The smallest positive integer 1 is missing.
2134
</pre>
35+
2236
<p>&nbsp;</p>
2337
<p><strong>Constraints:</strong></p>
2438

2539
<ul>
26-
<li><code>1 &lt;= nums.length &lt;= 5 * 10<sup>5</sup></code></li>
40+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
2741
<li><code>-2<sup>31</sup> &lt;= nums[i] &lt;= 2<sup>31</sup> - 1</code></li>
2842
</ul>
2943

‎solution/0100-0199/0125.Valid Palindrome/README.md‎

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,46 @@
66

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

9-
<p>给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。</p>
9+
<p>如果在将所有大写字符转换为小写字符、并移除所有非字母数字字符之后,短语正着读和反着读都一样。则可以认为该短语是一个回文串。</p>
1010

11-
<p><strong>说明:</strong>本题中,我们将空字符串定义为有效的回文串。</p>
11+
<p>字母和数字都属于字母数字字符。</p>
1212

13-
<p></p>
13+
<p>给你一个字符串 <code>s</code>,如果它是回文串,返回 <code>true</code><em> </em>;否则,返回<em> </em><code>false</code><em> </em>。</p>
1414

15-
<p><strong>示例 1:</strong></p>
15+
<p>&nbsp;</p>
16+
17+
<p><strong>示例 1:</strong></p>
1618

1719
<pre>
1820
<strong>输入:</strong> "A man, a plan, a canal: Panama"
19-
<strong>输出:</strong> true
20-
<strong>解释:</strong>"amanaplanacanalpanama" 是回文串
21+
<strong>输出:</strong>true
22+
<strong>解释:</strong>"amanaplanacanalpanama" 是回文串。
23+
</pre>
24+
25+
<p><strong>示例 2:</strong></p>
26+
27+
<pre>
28+
<strong>输入:</strong>"race a car"
29+
<strong>输出:</strong>false
30+
<strong>解释:</strong>"raceacar" 不是回文串。
2131
</pre>
2232

23-
<p><strong>示例 2:</strong></p>
33+
<p><strong>示例 3:</strong></p>
2434

2535
<pre>
26-
<strong>输入:</strong> "race a car"
27-
<strong>输出:</strong> false
28-
<strong>解释:</strong>"raceacar" 不是回文串
36+
<strong>输入:</strong>s = " "
37+
<strong>输出:</strong>true
38+
<strong>解释:</strong>在移除非字母数字字符之后,s 是一个空字符串 "" 。
39+
由于空字符串正着反着读都一样,所以是回文串。
2940
</pre>
3041

31-
<p></p>
42+
<p>&nbsp;</p>
3243

3344
<p><strong>提示:</strong></p>
3445

3546
<ul>
36-
<li><code>1 <= s.length <= 2 * 10<sup>5</sup></code></li>
37-
<li>字符串 <code>s</code> ASCII 字符组成</li>
47+
<li><code>1 &lt;= s.length &lt;= 2 * 10<sup>5</sup></code></li>
48+
<li><code>s</code> 仅由可打印的 ASCII 字符组成</li>
3849
</ul>
3950

4051
## 解法

‎solution/0100-0199/0151.Reverse Words in a String/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# [151. 颠倒字符串中的单词](https://leetcode.cn/problems/reverse-words-in-a-string)
1+
# [151. 反转字符串中的单词](https://leetcode.cn/problems/reverse-words-in-a-string)
22

33
[English Version](/solution/0100-0199/0151.Reverse%20Words%20in%20a%20String/README_EN.md)
44

55
## 题目描述
66

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

9-
<p>给你一个字符串 <code>s</code> ,颠倒字符串中 <strong>单词</strong> 的顺序。</p>
9+
<p>给你一个字符串 <code>s</code> ,请你反转字符串中 <strong>单词</strong> 的顺序。</p>
1010

1111
<p><strong>单词</strong> 是由非空格字符组成的字符串。<code>s</code> 中使用至少一个空格将字符串中的 <strong>单词</strong> 分隔开。</p>
1212

@@ -28,15 +28,15 @@
2828
<pre>
2929
<strong>输入:</strong>s = " &nbsp;hello world &nbsp;"
3030
<strong>输出:</strong>"world hello"
31-
<strong>解释:</strong>颠倒后的字符串中不能存在前导空格和尾随空格
31+
<strong>解释:</strong>反转后的字符串中不能存在前导空格和尾随空格
3232
</pre>
3333

3434
<p><strong>示例 3:</strong></p>
3535

3636
<pre>
3737
<strong>输入:</strong>s = "a good &nbsp; example"
3838
<strong>输出:</strong>"example good a"
39-
<strong>解释:</strong>如果两个单词间有多余的空格,颠倒后的字符串需要将单词间的空格减少到仅有一个
39+
<strong>解释:</strong>如果两个单词间有多余的空格,反转后的字符串需要将单词间的空格减少到仅有一个
4040
</pre>
4141

4242
<p>&nbsp;</p>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<li><code>skipB</code> - The number of nodes to skip ahead in <code>listB</code> (starting from the head) to get to the intersected node.</li>
2525
</ul>
2626

27-
<p>The judge will then create the linked structure based on these inputs and pass the two heads, <code>headA</code> and <code>headB</code>&nbsp;to your program. If you correctly return the intersected node, then your solution will be <strong>accepted</strong>.</p>
27+
<p>The judge will then create the linked structure based on these inputs and pass the two heads, <code>headA</code> and <code>headB</code>to your program. If you correctly return the intersected node, then your solution will be <strong>accepted</strong>.</p>
2828

2929
<p>&nbsp;</p>
3030
<p><strong>Example 1:</strong></p>
@@ -34,6 +34,7 @@
3434
<strong>Output:</strong> Intersected at &#39;8&#39;
3535
<strong>Explanation:</strong> The intersected node&#39;s value is 8 (note that this must not be 0 if the two lists intersect).
3636
From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,6,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B.
37+
- Note that the intersected node&#39;s value is not 1 because the nodes with value 1 in A and B (2<sup>nd</sup> node in A and 3<sup>rd</sup> node in B) are different node references. In other words, they point to two different locations in memory, while the nodes with value 8 in A and B (3<sup>rd</sup> node in A and 4<sup>th</sup> node in B) point to the same location in memory.
3738
</pre>
3839

3940
<p><strong>Example 2:</strong></p>

‎solution/0100-0199/0186.Reverse Words in a String II/README.md‎

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,48 @@
1-
# [186. 翻转字符串里的单词 II](https://leetcode.cn/problems/reverse-words-in-a-string-ii)
1+
# [186. 反转字符串中的单词 II](https://leetcode.cn/problems/reverse-words-in-a-string-ii)
22

33
[English Version](/solution/0100-0199/0186.Reverse%20Words%20in%20a%20String%20II/README_EN.md)
44

55
## 题目描述
66

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

9-
<p>给定一个字符串,逐个翻转字符串中的每个单词。</p>
9+
<p>给你一个字符数组 <code>s</code> ,反转其中 <strong>单词</strong> 的顺序。</p>
1010

11-
<p><strong>示例:</strong></p>
11+
<p><strong>单词</strong> 的定义为:单词是一个由非空格字符组成的序列。<code>s</code> 中的单词将会由单个空格分隔。</p>
1212

13-
<pre><strong>输入: </strong>[&quot;t&quot;,&quot;h&quot;,&quot;e&quot;,&quot; &quot;,&quot;s&quot;,&quot;k&quot;,&quot;y&quot;,&quot; &quot;,&quot;i&quot;,&quot;s&quot;,&quot; &quot;,&quot;b&quot;,&quot;l&quot;,&quot;u&quot;,&quot;e&quot;]
14-
<strong>输出: </strong>[&quot;b&quot;,&quot;l&quot;,&quot;u&quot;,&quot;e&quot;,&quot; &quot;,&quot;i&quot;,&quot;s&quot;,&quot; &quot;,&quot;s&quot;,&quot;k&quot;,&quot;y&quot;,&quot; &quot;,&quot;t&quot;,&quot;h&quot;,&quot;e&quot;]</pre>
13+
<div class="original__bRMd">
14+
<div>
15+
<p>必须设计并实现 <strong>原地</strong> 解法来解决此问题,即不分配额外的空间。</p>
1516

16-
<p><strong>注意:</strong></p>
17+
<p>&nbsp;</p>
18+
19+
<p><strong>示例 1:</strong></p>
20+
21+
<pre>
22+
<strong>输入:</strong>s = ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"]
23+
<strong>输出:</strong>["b","l","u","e"," ","i","s"," ","s","k","y"," ","t","h","e"]
24+
</pre>
25+
26+
<p><strong>示例 2:</strong></p>
27+
28+
<pre>
29+
<strong>输入:</strong>s = ["a"]
30+
<strong>输出:</strong>["a"]
31+
</pre>
32+
33+
<p>&nbsp;</p>
34+
35+
<p><strong>提示:</strong></p>
1736

1837
<ul>
19-
<li>单词的定义是不包含空格的一系列字符</li>
20-
<li>输入字符串中不会包含前置或尾随的空格</li>
21-
<li>单词与单词之间永远是以单个空格隔开的</li>
38+
<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
39+
<li><code>s[i]</code> 可以是一个英文字母(大写或小写)、数字、或是空格 <code>' '</code> 。</li>
40+
<li><code>s</code> 中至少存在一个单词</li>
41+
<li><code>s</code> 不含前导或尾随空格</li>
42+
<li>题目数据保证:<code>s</code> 中的每个单词都由单个空格分隔</li>
2243
</ul>
23-
24-
<p><strong>进阶:</strong>使用&nbsp;<em>O</em>(1) 额外空间复杂度的原地解法。</p>
44+
</div>
45+
</div>
2546

2647
## 解法
2748

‎solution/0200-0299/0277.Find the Celebrity/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ ans = 3
9595
ans not knows 4
9696
ans not knows 5
9797
ans not knows 6
98-
ans = 6
98+
ans = 6
9999
```
100100
101101
这里 $ans$ 认识 3ドル,ドル说明 $ans$ 不是名人(即 0ドル$ 不是名人),那么名人会是 1ドル$ 或者 2ドル$ 吗?不会!因为若 1ドル$ 或者 2ドル$ 是名人,那么 0ドル$ 应该认识 1ドル$ 或者 2ドル$ 才对,与前面的例子冲突。因此,我们可以直接将 $ans$ 更新为 $i$。

‎solution/0400-0499/0421.Maximum XOR of Two Numbers in an Array/README.md‎

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

99
<p>给你一个整数数组 <code>nums</code> ,返回<em> </em><code>nums[i] XOR nums[j]</code> 的最大运算结果,其中 <code>0 ≤ i ≤ j &lt; n</code> 。</p>
1010

11-
<p><strong>进阶:</strong>你可以在 <code>O(n)</code> 的时间解决这个问题吗?</p>
12-
1311
<p>&nbsp;</p>
1412

1513
<div class="original__bRMd">
@@ -23,27 +21,6 @@
2321

2422
<p><strong>示例 2:</strong></p>
2523

26-
<pre>
27-
<strong>输入:</strong>nums = [0]
28-
<strong>输出:</strong>0
29-
</pre>
30-
31-
<p><strong>示例 3:</strong></p>
32-
33-
<pre>
34-
<strong>输入:</strong>nums = [2,4]
35-
<strong>输出:</strong>6
36-
</pre>
37-
38-
<p><strong>示例 4:</strong></p>
39-
40-
<pre>
41-
<strong>输入:</strong>nums = [8,10,2]
42-
<strong>输出:</strong>10
43-
</pre>
44-
45-
<p><strong>示例 5:</strong></p>
46-
4724
<pre>
4825
<strong>输入:</strong>nums = [14,70,53,83,49,91,36,80,92,51,66,70]
4926
<strong>输出:</strong>127

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /