Skip to content

Commit 42bda89

Browse files
authored
chore: update lc problems (doocs#742)
1 parent 743214a commit 42bda89

File tree

2,415 files changed

+43964
-49607
lines changed

Some content is hidden

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

2,415 files changed

+43964
-49607
lines changed

README.md

+167-167
Large diffs are not rendered by default.

README_EN.md

+159-159
Large diffs are not rendered by default.

lcci/01.02.Check Permutation/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ impl Solution {
216216
}
217217
```
218218

219-
220219
### **...**
221220

222221
```

lcci/01.09.String Rotation/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function isFlipedString(s1: string, s2: string): boolean {
9898
```rust
9999
impl Solution {
100100
pub fn is_fliped_string(s1: String, s2: String) -> bool {
101-
s1.len() == s2.len() && (s2.clone() + &s2).contains(&s1)
101+
s1.len() == s2.len() && (s2.clone() + &s2).contains(&s1)
102102
}
103103
}
104104
```

lcci/01.09.String Rotation/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function isFlipedString(s1: string, s2: string): boolean {
7777
```rust
7878
impl Solution {
7979
pub fn is_fliped_string(s1: String, s2: String) -> bool {
80-
s1.len() == s2.len() && (s2.clone() + &s2).contains(&s1)
80+
s1.len() == s2.len() && (s2.clone() + &s2).contains(&s1)
8181
}
8282
}
8383
```

lcci/02.01.Remove Duplicate Node/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -235,20 +235,20 @@ function removeDuplicateNodes(head: ListNode | null): ListNode | null {
235235
*/
236236

237237
function removeDuplicateNodes(head: ListNode | null): ListNode | null {
238-
let n1 = head
238+
let n1 = head;
239239
while (n1 != null) {
240-
let n2 = n1
240+
let n2 = n1;
241241
while (n2.next != null) {
242242
if (n1.val === n2.next.val) {
243243
n2.next = n2.next.next;
244244
} else {
245245
n2 = n2.next;
246246
}
247247
}
248-
n1 = n1.next
248+
n1 = n1.next;
249249
}
250-
return head
251-
};
250+
return head;
251+
}
252252
```
253253

254254
### **Rust**

lcci/02.01.Remove Duplicate Node/README_EN.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -235,20 +235,20 @@ Violence (not recommended)
235235
*/
236236

237237
function removeDuplicateNodes(head: ListNode | null): ListNode | null {
238-
let n1 = head
238+
let n1 = head;
239239
while (n1 != null) {
240-
let n2 = n1
240+
let n2 = n1;
241241
while (n2.next != null) {
242242
if (n1.val === n2.next.val) {
243243
n2.next = n2.next.next;
244244
} else {
245245
n2 = n2.next;
246246
}
247247
}
248-
n1 = n1.next
248+
n1 = n1.next;
249249
}
250-
return head
251-
};
250+
return head;
251+
}
252252
```
253253

254254
### **Rust**

lcci/02.05.Sum Lists/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ function addTwoNumbers(
234234
}
235235
```
236236

237-
238237
### **Rust**
239238

240239
```rust

lcci/02.05.Sum Lists/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ function addTwoNumbers(
229229
}
230230
```
231231

232-
233232
### **Rust**
234233

235234
```rust

lcci/04.02.Minimum Height Tree/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ impl Solution {
228228
}
229229
```
230230

231-
232231
### **...**
233232

234233
```

lcci/10.10.Rank from Stream/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ class StreamRank {
136136
public StreamRank() {
137137
tree = new BinaryIndexedTree(50010);
138138
}
139-
139+
140140
public void track(int x) {
141141
tree.update(x + 1, 1);
142142
}
143-
143+
144144
public int getRankOfNumber(int x) {
145145
return tree.query(x + 1);
146146
}
@@ -194,11 +194,11 @@ public:
194194
StreamRank() {
195195
tree = new BinaryIndexedTree(50010);
196196
}
197-
197+
198198
void track(int x) {
199199
tree->update(x + 1, 1);
200200
}
201-
201+
202202
int getRankOfNumber(int x) {
203203
return tree->query(x + 1);
204204
}

lcci/10.10.Rank from Stream/README_EN.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ class StreamRank {
119119
public StreamRank() {
120120
tree = new BinaryIndexedTree(50010);
121121
}
122-
122+
123123
public void track(int x) {
124124
tree.update(x + 1, 1);
125125
}
126-
126+
127127
public int getRankOfNumber(int x) {
128128
return tree.query(x + 1);
129129
}
@@ -177,11 +177,11 @@ public:
177177
StreamRank() {
178178
tree = new BinaryIndexedTree(50010);
179179
}
180-
180+
181181
void track(int x) {
182182
tree->update(x + 1, 1);
183183
}
184-
184+
185185
int getRankOfNumber(int x) {
186186
return tree->query(x + 1);
187187
}

lcof/面试题55 - I. 二叉树的深度/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func maxDepth(root *TreeNode) int {
147147
// pub left: Option<Rc<RefCell<TreeNode>>>,
148148
// pub right: Option<Rc<RefCell<TreeNode>>>,
149149
// }
150-
//
150+
//
151151
// impl TreeNode {
152152
// #[inline]
153153
// pub fn new(val: i32) -> Self {

lcof2/剑指 Offer II 014. 字符串中的变位词/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public:
183183
if (r + 1 >= len2) {
184184
break;
185185
}
186-
186+
187187
++count[s2[l++] - 'a'];
188188
--count[s2[++r] - 'a'];
189189
}

lcs/LCS 02. 完成一半题目/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func halfQuestions(questions []int) int {
130130
* @param {number[]} questions
131131
* @return {number}
132132
*/
133-
var halfQuestions = function(questions) {
133+
var halfQuestions = function (questions) {
134134
let counter = new Array(1010).fill(0);
135135
for (const q of questions) {
136136
++counter[q];

lcs/LCS 03. 主题空间/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
2929
**提示:**
3030

31-
- `1 <= grid.length <= 500`
32-
- `1 <= grid[i].length <= 500`
33-
- `grid[i][j]` 仅可能是 `"0"~"5"`
31+
- `1 <= grid.length <= 500`
32+
- `1 <= grid[i].length <= 500`
33+
- `grid[i][j]` 仅可能是 `"0"~"5"`
3434

3535
## 解法
3636

@@ -99,9 +99,9 @@ d[find(a)] = distance
9999

100100
对于本题,记 m, n 分别为 grid 的行数和列数。
101101

102-
- 将所有走廊及 "0" 对应的格子与超级节点 `m * n` 相连。
103-
- 对于其它格子,判断其相邻(上、下、左、右)的格子是否为 "0" 或者与当前格子相同,若是,更新 size 并将两个格子相连。
104-
- 最后,获取不与超级节点相连的格子的最大 size,即为答案。
102+
- 将所有走廊及 "0" 对应的格子与超级节点 `m * n` 相连。
103+
- 对于其它格子,判断其相邻(上、下、左、右)的格子是否为 "0" 或者与当前格子相同,若是,更新 size 并将两个格子相连。
104+
- 最后,获取不与超级节点相连的格子的最大 size,即为答案。
105105

106106
<!-- tabs:start -->
107107

solution/0000-0099/0001.Two Sum/README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

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

9-
<p>给定一个整数数组 <code>nums</code> 和一个整数目标值 <code>target</code>,请你在该数组中找出 <strong>和为目标值</strong> 的那 <strong>两个</strong> 整数,并返回它们的数组下标。</p>
9+
<p>给定一个整数数组 <code>nums</code>&nbsp;和一个整数目标值 <code>target</code>,请你在该数组中找出 <strong>和为目标值 </strong><em><code>target</code></em>&nbsp; 的那&nbsp;<strong>两个</strong>&nbsp;整数,并返回它们的数组下标。</p>
1010

1111
<p>你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。</p>
1212

1313
<p>你可以按任意顺序返回答案。</p>
1414

15-
<p> </p>
15+
<p>&nbsp;</p>
1616

1717
<p><strong>示例 1:</strong></p>
1818

@@ -36,17 +36,19 @@
3636
<strong>输出:</strong>[0,1]
3737
</pre>
3838

39-
<p> </p>
39+
<p>&nbsp;</p>
4040

4141
<p><strong>提示:</strong></p>
4242

4343
<ul>
44-
<li><code>2 <= nums.length <= 10<sup>3</sup></code></li>
45-
<li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li>
46-
<li><code>-10<sup>9</sup> <= target <= 10<sup>9</sup></code></li>
44+
<li><code>2 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
45+
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
46+
<li><code>-10<sup>9</sup> &lt;= target &lt;= 10<sup>9</sup></code></li>
4747
<li><strong>只会存在一个有效答案</strong></li>
4848
</ul>
4949

50+
<p><strong>进阶:</strong>你可以想出一个时间复杂度小于 <code>O(n<sup>2</sup>)</code> 的算法吗?</p>
51+
5052
## 解法
5153

5254
<!-- 这里可写通用的实现逻辑 -->

solution/0000-0099/0001.Two Sum/README_EN.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@
3737
<p><strong>Constraints:</strong></p>
3838

3939
<ul>
40-
<li><code>2 &lt;= nums.length &lt;= 10<sup>3</sup></code></li>
40+
<li><code>2 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
4141
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
4242
<li><code>-10<sup>9</sup> &lt;= target &lt;= 10<sup>9</sup></code></li>
4343
<li><strong>Only one valid answer exists.</strong></li>
4444
</ul>
4545

46+
<p>&nbsp;</p>
47+
<strong>Follow-up:&nbsp;</strong>Can you come up with an algorithm that is less than&nbsp;<code>O(n<sup>2</sup>)&nbsp;</code>time complexity?
48+
4649
## Solutions
4750

4851
<!-- tabs:start -->

solution/0000-0099/0003.Longest Substring Without Repeating Characters/README.md

+9-16
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

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

9-
<p>给定一个字符串,请你找出其中不含有重复字符的 <strong>最长子串 </strong>的长度。</p>
9+
<p>给定一个字符串 <code>s</code> ,请你找出其中不含有重复字符的&nbsp;<strong>最长子串&nbsp;</strong>的长度。</p>
1010

11-
<p> </p>
11+
<p>&nbsp;</p>
1212

13-
<p><strong>示例 1:</strong></p>
13+
<p><strong>示例&nbsp;1:</strong></p>
1414

1515
<pre>
1616
<strong>输入: </strong>s = "abcabcbb"
17-
<strong>输出: </strong>3
17+
<strong>输出: </strong>3
1818
<strong>解释:</strong> 因为无重复字符的最长子串是 <code>"abc",所以其</code>长度为 3。
1919
</pre>
2020

@@ -31,24 +31,17 @@
3131
<pre>
3232
<strong>输入: </strong>s = "pwwkew"
3333
<strong>输出: </strong>3
34-
<strong>解释: </strong>因为无重复字符的最长子串是 <code>"wke"</code>,所以其长度为 3。
35-
  请注意,你的答案必须是 <strong>子串 </strong>的长度,<code>"pwke"</code> 是一个<em>子序列,</em>不是子串。
36-
</pre>
37-
38-
<p><strong>示例 4:</strong></p>
39-
40-
<pre>
41-
<strong>输入: </strong>s = ""
42-
<strong>输出: </strong>0
34+
<strong>解释: </strong>因为无重复字符的最长子串是&nbsp;<code>"wke"</code>,所以其长度为 3。
35+
&nbsp; 请注意,你的答案必须是 <strong>子串 </strong>的长度,<code>"pwke"</code>&nbsp;是一个<em>子序列,</em>不是子串。
4336
</pre>
4437

45-
<p> </p>
38+
<p>&nbsp;</p>
4639

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

4942
<ul>
50-
<li><code>0 <= s.length <= 5 * 10<sup>4</sup></code></li>
51-
<li><code>s</code> 由英文字母、数字、符号和空格组成</li>
43+
<li><code>0 &lt;= s.length &lt;= 5 * 10<sup>4</sup></code></li>
44+
<li><code>s</code>&nbsp;由英文字母、数字、符号和空格组成</li>
5245
</ul>
5346

5447
## 解法

solution/0000-0099/0003.Longest Substring Without Repeating Characters/README_EN.md

+1-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Description
66

7-
<p>Given a string <code>s</code>, find the length of the <b>longest substring</b> without repeating characters.</p>
7+
<p>Given a string <code>s</code>, find the length of the <strong>longest substring</strong> without repeating characters.</p>
88

99
<p>&nbsp;</p>
1010
<p><strong>Example 1:</strong></p>
@@ -32,13 +32,6 @@
3232
Notice that the answer must be a substring, &quot;pwke&quot; is a subsequence and not a substring.
3333
</pre>
3434

35-
<p><strong>Example 4:</strong></p>
36-
37-
<pre>
38-
<strong>Input:</strong> s = &quot;&quot;
39-
<strong>Output:</strong> 0
40-
</pre>
41-
4235
<p>&nbsp;</p>
4336
<p><strong>Constraints:</strong></p>
4437

0 commit comments

Comments
 (0)