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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 8 additions & 8 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 8 additions & 8 deletions
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

Lines changed: 8 additions & 8 deletions
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

Lines changed: 6 additions & 8 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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
<!-- 这里可写通用的实现逻辑 -->

0 commit comments

Comments
 (0)