Skip to content

Commit ddd6a95

Browse files
committed
feat: add contest data
1 parent 460a8f2 commit ddd6a95

File tree

187 files changed

+9875
-9727
lines changed

Some content is hidden

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

187 files changed

+9875
-9727
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.vscode
44
/node_modules
55
/solution/result.json
6+
/solution/contest.json
67
/solution/raw.json
78
/lcof/lcof.json
89
/lcof/lcof_list.json

basic/sorting/CountingSort/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
计数排序是一个非基于比较的排序算法,是一种空间换时间的算法,是通过元素的值来确定元素的位置, 适用于非负整数的排序(如果负数需要排序,那么需要使所有元素都添加上 `0-min` 之后再减去该值)
44

55
算法描述:
6-
- 给定原数组中元素值的范围 `[min, max]`
7-
- 创建一个新数组 `c` ,其长度是 `max-min+1`,其元素默认值都是 `0`
8-
- 遍历原数组中的元素,以原数组中的元素作为 `c` 数组的索引,以原数组中的元素出现次数作为 `c` 数组的元素值。
9-
- 创建结果数组 `r`,起始索引 `i`
10-
- 遍历数组 `c`,找出其中元素大于 `0` 的元素,将其对应的索引作为元素值填充到 `r` 数组中,每处理一次,`c` 中的元素值减 `1`,直到该元素值不大于 `0`,依次处理 `c` 中剩下的元素
6+
7+
- 给定原数组中元素值的范围 `[min, max]`
8+
- 创建一个新数组 `c` ,其长度是 `max-min+1`,其元素默认值都是 `0`
9+
- 遍历原数组中的元素,以原数组中的元素作为 `c` 数组的索引,以原数组中的元素出现次数作为 `c` 数组的元素值。
10+
- 创建结果数组 `r`,起始索引 `i`
11+
- 遍历数组 `c`,找出其中元素大于 `0` 的元素,将其对应的索引作为元素值填充到 `r` 数组中,每处理一次,`c` 中的元素值减 `1`,直到该元素值不大于 `0`,依次处理 `c` 中剩下的元素
1112

1213
## 代码示例
1314

@@ -68,6 +69,5 @@ func CountingSort(nums []int, min, max int) {
6869

6970
## 算法分析
7071

71-
- 时间复杂度 `O(n+k)`, 其中 `n` 为排序数组长度,`k` 为排序数组中数值的取值范围,当 `k < n` 时,时间复杂度为 `O(n)`
72-
- 空间复杂度 `O(n+k)`, 其中 `n` 为排序数组长度,`k` 为排序数组中数值的取值范围,当 `k < n` 时,空间复杂度为 `O(n)`
73-
72+
- 时间复杂度 `O(n+k)`, 其中 `n` 为排序数组长度,`k` 为排序数组中数值的取值范围,当 `k < n` 时,时间复杂度为 `O(n)`
73+
- 空间复杂度 `O(n+k)`, 其中 `n` 为排序数组长度,`k` 为排序数组中数值的取值范围,当 `k < n` 时,空间复杂度为 `O(n)`

basic/sorting/HeapSort/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ fn main() -> io::Result<()> {
225225
```
226226

227227
### **Go**
228+
228229
```go
229230
package main
230231

lcci/03.05.Sort of Stacks/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -160,33 +160,33 @@ class SortedStack {
160160

161161
```ts
162162
class SortedStack {
163-
private stack: number[]
163+
private stack: number[];
164164

165165
constructor() {
166-
this.stack = []
166+
this.stack = [];
167167
}
168168

169169
push(val: number): void {
170170
if (this.isEmpty() || this.peek() > val) {
171-
this.stack.push(val)
172-
return
171+
this.stack.push(val);
172+
return;
173173
}
174174

175-
const tmp = this.stack.pop()
175+
const tmp = this.stack.pop();
176176
this.push(val);
177177
this.stack.push(tmp);
178178
}
179179

180180
pop(): void {
181-
this.stack.pop()
181+
this.stack.pop();
182182
}
183183

184184
peek(): number {
185-
return this.stack[this.stack.length - 1] ?? -1
185+
return this.stack[this.stack.length - 1] ?? -1;
186186
}
187187

188188
isEmpty(): boolean {
189-
return this.stack.length === 0
189+
return this.stack.length === 0;
190190
}
191191
}
192192

lcci/03.05.Sort of Stacks/README_EN.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -165,33 +165,33 @@ class SortedStack {
165165

166166
```ts
167167
class SortedStack {
168-
private stack: number[]
168+
private stack: number[];
169169

170170
constructor() {
171-
this.stack = []
171+
this.stack = [];
172172
}
173173

174174
push(val: number): void {
175175
if (this.isEmpty() || this.peek() > val) {
176-
this.stack.push(val)
177-
return
176+
this.stack.push(val);
177+
return;
178178
}
179179

180-
const tmp = this.stack.pop()
180+
const tmp = this.stack.pop();
181181
this.push(val);
182182
this.stack.push(tmp);
183183
}
184184

185185
pop(): void {
186-
this.stack.pop()
186+
this.stack.pop();
187187
}
188188

189189
peek(): number {
190-
return this.stack[this.stack.length - 1] ?? -1
190+
return this.stack[this.stack.length - 1] ?? -1;
191191
}
192192

193193
isEmpty(): boolean {
194-
return this.stack.length === 0
194+
return this.stack.length === 0;
195195
}
196196
}
197197

lcci/04.06.Successor/README.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737

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

40-
41-
4240
<!-- tabs:start -->
4341

4442
### **Python3**
@@ -225,17 +223,17 @@ func inorderSuccessor(root *TreeNode, p *TreeNode) *TreeNode {
225223
*/
226224
var inorderSuccessor = function (root, p) {
227225
if (root == null) {
228-
return root
226+
return root;
229227
}
230-
const { val, left, right } = root
231-
const res = inorderSuccessor(left, p)
228+
const { val, left, right } = root;
229+
const res = inorderSuccessor(left, p);
232230
if (res != null) {
233-
return res
231+
return res;
234232
}
235233
if (val > p.val) {
236-
return root
234+
return root;
237235
}
238-
return inorderSuccessor(right, p)
236+
return inorderSuccessor(right, p);
239237
};
240238
```
241239

lcci/04.06.Successor/README_EN.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,17 @@ func inorderSuccessor(root *TreeNode, p *TreeNode) *TreeNode {
236236
*/
237237
var inorderSuccessor = function (root, p) {
238238
if (root == null) {
239-
return root
239+
return root;
240240
}
241-
const { val, left, right } = root
242-
const res = inorderSuccessor(left, p)
241+
const { val, left, right } = root;
242+
const res = inorderSuccessor(left, p);
243243
if (res != null) {
244-
return res
244+
return res;
245245
}
246246
if (val > p.val) {
247-
return root
247+
return root;
248248
}
249-
return inorderSuccessor(right, p)
249+
return inorderSuccessor(right, p);
250250
};
251251
```
252252

lcof/面试题13. 机器人的运动范围/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040
2. 根据公式判断 `(i, j)` 是否可进入:
4141

42-
- 可进入,并继续往右 `(i, j + 1)` 往下 `(i + 1, j)` 重新执行流程 2。
43-
- 不可进入,退出结算。
42+
- 可进入,并继续往右 `(i, j + 1)` 往下 `(i + 1, j)` 重新执行流程 2。
43+
- 不可进入,退出结算。
4444

4545
3. 计算可进入区域的数量,返回即可。
4646

lcof/面试题57. 和为s的两个数字/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
- 存在,即 `return` 返回。
3737
- 不存在,记录元素,继续遍历。
3838

39-
*复杂度*
39+
_复杂度_
4040

4141
- 时间 **_O(N)_**
4242
- 空间 **_O(N)_**
@@ -52,7 +52,7 @@
5252

5353
> 因为数组是有序的,指针变动对值的影响可预测。
5454
55-
*复杂度*
55+
_复杂度_
5656

5757
- 时间 **_O(N)_**
5858
- 空间 **_O(1)_**

solution/0000-0099/0006.Zigzag Conversion/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ string convert(string s, int numRows);</pre>
3030
<strong>输入:</strong>s = "PAYPALISHIRING", numRows = 3
3131
<strong>输出:</strong>"PAHNAPLSIIGYIR"
3232
</pre>
33+
3334
<strong>示例 2:</strong>
3435

3536
<pre>
@@ -59,7 +60,6 @@ P I
5960
<li><code>1 <= numRows <= 1000</code></li>
6061
</ul>
6162

62-
6363
## 解法
6464

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

solution/0000-0099/0006.Zigzag Conversion/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ P I
5656
<li><code>1 &lt;= numRows &lt;= 1000</code></li>
5757
</ul>
5858

59-
6059
## Solutions
6160

6261
<!-- tabs:start -->

solution/0000-0099/0028.Implement strStr()/README.md

-9
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
<p>给你两个字符串&nbsp;<code>haystack</code> 和 <code>needle</code> ,请你在 <code>haystack</code> 字符串中找出 <code>needle</code> 字符串出现的第一个位置(下标从 0 开始)。如果不存在,则返回&nbsp; <code>-1</code><strong> </strong>。</p>
1212

13-
<p>&nbsp;</p>
14-
1513
<p><strong>说明:</strong></p>
1614

1715
<p>当&nbsp;<code>needle</code>&nbsp;是空字符串时,我们应当返回什么值呢?这是一个在面试中很好的问题。</p>
@@ -34,13 +32,6 @@
3432
<strong>输出:</strong>-1
3533
</pre>
3634

37-
<p><strong>示例 3:</strong></p>
38-
39-
<pre>
40-
<strong>输入:</strong>haystack = "", needle = ""
41-
<strong>输出:</strong>0
42-
</pre>
43-
4435
<p>&nbsp;</p>
4536

4637
<p><strong>提示:</strong></p>

solution/0000-0099/0038.Count and Say/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<li><code>countAndSay(n)</code> is the way you would &quot;say&quot; the digit string from <code>countAndSay(n-1)</code>, which is then converted into a different digit string.</li>
1212
</ul>
1313

14-
<p>To determine how you &quot;say&quot; a digit string, split it into the <strong>minimal</strong> number of groups so that each group is a contiguous section all of the <strong>same character.</strong> Then for each group, say the number of characters, then say the character. To convert the saying into a digit string, replace the counts with a number and concatenate every saying.</p>
14+
<p>To determine how you &quot;say&quot; a digit string, split it into the <strong>minimal</strong> number of substrings such that each substring contains exactly <strong>one</strong> unique digit. Then for each substring, say the number of digits, then say the digit. Finally, concatenate every said digit.</p>
1515

1616
<p>For example, the saying and conversion for digit string <code>&quot;3322251&quot;</code>:</p>
1717
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0038.Count%20and%20Say/images/countandsay.jpg" style="width: 581px; height: 172px;" />

solution/0000-0099/0051.N-Queens/README.md

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

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

9+
<p>按照国际象棋的规则,皇后可以攻击与之处在同一行或同一列或同一斜线上的棋子。</p>
10+
911
<p><strong>n&nbsp;皇后问题</strong> 研究的是如何将 <code>n</code>&nbsp;个皇后放置在 <code>n×n</code> 的棋盘上,并且使皇后彼此之间不能相互攻击。</p>
1012

1113
<p>给你一个整数 <code>n</code> ,返回所有不同的&nbsp;<strong>n<em>&nbsp;</em>皇后问题</strong> 的解决方案。</p>

solution/0000-0099/0057.Insert Interval/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Solution:
8989
ed = max(ed, e)
9090
ans.append([st, ed])
9191
return ans
92-
92+
9393
intervals.append(newInterval)
9494
return merge(intervals)
9595
```

solution/0000-0099/0057.Insert Interval/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Solution:
5959
ed = max(ed, e)
6060
ans.append([st, ed])
6161
return ans
62-
62+
6363
intervals.append(newInterval)
6464
return merge(intervals)
6565
```

solution/0000-0099/0058.Length of Last Word/README_EN.md

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

55
## Description
66

7-
<p>Given a string <code>s</code> consisting&nbsp;of some words separated by some number of spaces, return <em>the length of the <strong>last</strong> word in the string.</em></p>
7+
<p>Given a string <code>s</code> consisting of words and spaces, return <em>the length of the <strong>last</strong> word in the string.</em></p>
88

99
<p>A <strong>word</strong> is a maximal substring consisting of non-space characters only.</p>
1010

solution/0100-0199/0146.LRU Cache/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ lRUCache.get(4); // 返回 4
5757
<li>最多调用 <code>2 * 10<sup>5</sup></code> 次 <code>get</code> 和 <code>put</code></li>
5858
</ul>
5959

60-
6160
## 解法
6261

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

solution/0100-0199/0146.LRU Cache/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ lRUCache.get(4); // return 4
4949
<li>At most 2<code>&nbsp;* 10<sup>5</sup></code>&nbsp;calls will be made to <code>get</code> and <code>put</code>.</li>
5050
</ul>
5151

52-
5352
## Solutions
5453

5554
<!-- tabs:start -->

solution/0100-0199/0158.Read N Characters Given read4 II - Call Multiple Times/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ sol.read (buf, 1); // 我们已经到达文件的末尾,不能读取更多的
102102
<li><code>1 &lt;= queries[i] &lt;= 500</code></li>
103103
</ul>
104104

105-
106105
## 解法
107106

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

solution/0100-0199/0158.Read N Characters Given read4 II - Call Multiple Times/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ sol.read(buf, 1); // We have reached the end of file, no more characters can be
9797
<li><code>1 &lt;= queries[i] &lt;= 500</code></li>
9898
</ul>
9999

100-
101100
## Solutions
102101

103102
<!-- tabs:start -->

solution/0100-0199/0171.Excel Sheet Column Number/README_EN.md

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

55
## Description
66

7-
<p>Given a string <code>columnTitle</code> that represents the column title as appear in an Excel sheet, return <em>its corresponding column number</em>.</p>
7+
<p>Given a string <code>columnTitle</code> that represents the column title as appears in an Excel sheet, return <em>its corresponding column number</em>.</p>
88

99
<p>For example:</p>
1010

solution/0100-0199/0175.Combine Two Tables/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
| FirstName | varchar |
1717
| LastName | varchar |
1818
+-------------+---------+
19-
personId是该表的主键列
20-
该表包含一些人的ID和他们的姓和名的信息
19+
personId 是该表的主键列
20+
该表包含一些人的 ID 和他们的姓和名的信息
2121
</pre>
2222

2323
<p>&nbsp;</p>
@@ -33,13 +33,13 @@ personId是该表的主键列。
3333
| City | varchar |
3434
| State | varchar |
3535
+-------------+---------+
36-
addressId是该表的主键列
37-
该表的每一行都包含一个ID = PersonId的人的城市和州的信息
36+
addressId 是该表的主键列
37+
该表的每一行都包含一个 ID = PersonId 的人的城市和州的信息
3838
</pre>
3939

4040
<p>&nbsp;</p>
4141

42-
<p>编写一个SQL查询来报告 <code>Person</code> 表中每个人的姓、名、城市和状态。如果 <code>personId</code> 的地址不在&nbsp;<code>Address</code>&nbsp;表中,则报告为空 &nbsp;<code>null</code>&nbsp;。</p>
42+
<p>编写一个SQL查询来报告 <code>Person</code> 表中每个人的姓、名、城市和州。如果 <code>personId</code> 的地址不在&nbsp;<code>Address</code>&nbsp;表中,则报告为空 &nbsp;<code>null</code>&nbsp;。</p>
4343

4444
<p>以 <strong>任意顺序</strong> 返回结果表。</p>
4545

@@ -73,7 +73,7 @@ Address表:
7373
| Bob | Alice | New York City | New York |
7474
+-----------+----------+---------------+----------+
7575
<strong>解释:</strong>
76-
地址表中没有 personId = 1 的地址,所以它们的城市和州返回null
76+
地址表中没有 personId = 1 的地址,所以它们的城市和州返回 null
7777
addressId = 1 包含了 personId = 2 的地址信息。</pre>
7878

7979
## 解法

solution/0100-0199/0191.Number of 1 Bits/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ var hammingWeight = function (n) {
177177
};
178178
```
179179

180-
181180
### **Rust**
182181

183182
```rust

0 commit comments

Comments
 (0)