Skip to content

Commit 5e911d8

Browse files
committed
add 2458
1 parent 8d7405c commit 5e911d8

24 files changed

+4219
-3734
lines changed

assets/output/3329.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# [3329. 字符至少出现 K 次的子字符串 II](https://leetcode.com/problems/count-substrings-with-k-frequency-characters-ii)
2+
3+
🔴 <font color=#ff334b>Hard</font>&emsp; 🔖&ensp; [`哈希表`](/tag/hash-table.md) [`字符串`](/tag/string.md) [`滑动窗口`](/tag/sliding-window.md)&emsp; 🔗&ensp;[`LeetCode`](https://leetcode.com/problems/count-substrings-with-k-frequency-characters-ii)
4+
5+
## 题目
6+
7+
## 题目大意
8+
9+
## 解题思路
10+
11+
#### 复杂度分析
12+
13+
- **时间复杂度**`O()`
14+
- **空间复杂度**`O()`
15+
16+
## 代码
17+
18+
```javascript
19+
20+
```

assets/scripts/gen-docs.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ def gen_plan_list(plan_name, salt=False, path=None):
173173
f = open(origin_path, encoding='utf-8')
174174
lines = f.readlines()
175175
file_content = ""
176-
count = 0
177176

178177
for i in range(len(lines)):
179178
pattern = re.compile(r'(#{1,6}) (.*)')
@@ -206,6 +205,27 @@ def gen_plan_list(plan_name, salt=False, path=None):
206205
print("Create " + plan_name + " Success")
207206

208207

208+
def update_content():
209+
files = os.listdir(const.problem_path)
210+
for file in files:
211+
# 判断是否是文件夹
212+
if ".md" not in file:
213+
continue
214+
if "README" in file:
215+
continue
216+
print(Path(file))
217+
old_path = os.path.join(const.problem_path, Path(file))
218+
old_content = Path(old_path).read_text(encoding='utf-8')
219+
220+
new_path = os.path.join('../output/', Path(file))
221+
new_content = Path(new_path).read_text(encoding='utf-8')
222+
223+
delim = '## 解题思路\n'
224+
225+
text = new_content.split(delim)[0] + delim + old_content.split(delim)[1]
226+
227+
Path(old_path).write_text(text, encoding='utf-8')
228+
209229
# 更新题目详解页面的相关题目和标签
210230

211231
def update_similar():

assets/scripts/leetcode-spider.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import sqlite3
55
import json
6-
import traceback
76
import html2text
87
import os
98
import requests
@@ -13,7 +12,6 @@
1312
import argparse,sys
1413
import threading
1514
import pandas as pd
16-
import const
1715
import utils
1816

1917
db_path = 'leetcode.db'
@@ -336,6 +334,7 @@ def generate_questions_list(self):
336334
}
337335
res.append(question_detail)
338336

337+
res.sort(key=lambda x: x['fileName']) # 对 res 进行排序
339338
with open(file_name, 'w', encoding='utf-8', newline='') as f:
340339
import csv
341340
writer = csv.DictWriter(f, fieldnames=res[0].keys())
@@ -387,7 +386,7 @@ def generate_question_markdown(self, question, path, has_get_code):
387386
contentCN = html2text.html2text(textCN).replace(" \n \n **Input:**", "> Input:").replace(" **Output:**", "> \n> Output:").replace(' **Explanation:**', '> \n> Explanation:').replace(' - ', '> - ').replace(' \n\n**Example', '\n**Example').replace(' \n\n\n\n**Constraints:', '\n**Constraints:').replace(' ', '> \n> ').replace('103`', '10^3`').replace('104`', '10^4`').replace('105`', '10^5`').replace('106`', '10^6`').replace('107`', '10^7`').replace('108`', '10^8`').replace('109`', '10^9`').replace('`-103', '`-10^3').replace('`-104', '`-10^4').replace('`-105', '`-10^5').replace('`-106', '`-10^6').replace('`-107', '`-10^7').replace('`-108', '`-10^8').replace('`-109', '`-10^9')
388387
f.write(contentCN)
389388

390-
f.write("\n## 解题思路\n\n#### 复杂度分析\n\n- **时间复杂度**:`O()`,\n- **空间复杂度**:`O()`,\n\n## 代码\n\n```javascript\n\n```")
389+
f.write("\n\n## 解题思路\n\n#### 复杂度分析\n\n- **时间复杂度**:`O()`,\n- **空间复杂度**:`O()`,\n\n## 代码\n\n```javascript\n\n```")
391390

392391
similar = json.loads(question['similar'])
393392
if len(similar) > 0:
@@ -488,9 +487,9 @@ def close_db(self):
488487

489488

490489
test.connect_db(db_path)
491-
test.get_problems(filters)
490+
# test.get_problems(filters)
492491

493-
test.generate_questions_list()
492+
# test.generate_questions_list()
494493
test.generate_questions_markdown(args.output, filters)
495494

496495
test.close_db()

assets/scripts/problem-list.csv

Lines changed: 3711 additions & 3710 deletions
Large diffs are not rendered by default.

src/.vuepress/sidebar.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ export default sidebar({
519519
"children": [
520520
"2406",
521521
"2416",
522+
"2458",
522523
"2491"
523524
]
524525
},
@@ -540,6 +541,7 @@ export default sidebar({
540541
"2621",
541542
"2622",
542543
"2623",
544+
"2624",
543545
"2625",
544546
"2626",
545547
"2627",

src/offer2/jz_offer_II_105.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
## 解题思路
4242

43-
这道题和 [第 200 题 岛屿数量](./0200.md) 的解题思路是一样的,只不过需要给 dfs 函数加一个返回值,记录岛屿的面积。
43+
这道题和 [第 200 题 岛屿数量](../problem/0200.md) 的解题思路是一样的,只不过需要给 dfs 函数加一个返回值,记录岛屿的面积。
4444

4545
遍历整个网格,并在每次找到一个陆地单元时,使用深度优先搜索(DFS)或广度优先搜索(BFS)来遍历所有相连的陆地单元,从而将整个岛屿标记为已访问。
4646

src/plan/contest_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ headerDepth: 0
18621862
| 2455 | [可被三整除的偶数的平均值](https://leetcode.com/problems/average-value-of-even-numbers-that-are-divisible-by-three) | | [`数组`](/tag/array.md) [`数学`](/tag/math.md) | <font color=#15bd66>Easy</font> |
18631863
| 2456 | [最流行的视频创作者](https://leetcode.com/problems/most-popular-video-creator) | | [`数组`](/tag/array.md) [`哈希表`](/tag/hash-table.md) [`字符串`](/tag/string.md) `2+` | <font color=#ffb800>Medium</font> |
18641864
| 2457 | [美丽整数的最小增量](https://leetcode.com/problems/minimum-addition-to-make-integer-beautiful) | | [`贪心`](/tag/greedy.md) [`数学`](/tag/math.md) | <font color=#ffb800>Medium</font> |
1865-
| 2458 | [移除子树后的二叉树高度](https://leetcode.com/problems/height-of-binary-tree-after-subtree-removal-queries) | | [`树`](/tag/tree.md) [`深度优先搜索`](/tag/depth-first-search.md) [`广度优先搜索`](/tag/breadth-first-search.md) `2+` | <font color=#ff334b>Hard</font> |
1865+
| 2458 | [移除子树后的二叉树高度](https://leetcode.com/problems/height-of-binary-tree-after-subtree-removal-queries) | [[✓]](/problem/2458.md) | [`树`](/tag/tree.md) [`深度优先搜索`](/tag/depth-first-search.md) [`广度优先搜索`](/tag/breadth-first-search.md) `2+` | <font color=#ff334b>Hard</font> |
18661866

18671867

18681868
## Biweekly Contest 90 (2022-10-29 22:30)

src/plan/js_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ headerDepth: 0
1414
| 2621 | [睡眠函数](https://leetcode.com/problems/sleep) | [[]](/problem/2621.md) | | <font color=#15bd66>Easy</font> |
1515
| 2622 | [有时间限制的缓存](https://leetcode.com/problems/cache-with-time-limit) | [[]](/problem/2622.md) | | <font color=#ffb800>Medium</font> |
1616
| 2623 | [记忆函数](https://leetcode.com/problems/memoize) | [[]](/problem/2623.md) | | <font color=#ffb800>Medium</font> |
17-
| 2624 | [蜗牛排序](https://leetcode.com/problems/snail-traversal) | | | <font color=#ffb800>Medium</font> |
17+
| 2624 | [蜗牛排序](https://leetcode.com/problems/snail-traversal) | [[]](/problem/2624.md) | | <font color=#ffb800>Medium</font> |
1818
| 2625 | [扁平化嵌套数组](https://leetcode.com/problems/flatten-deeply-nested-array) | [[]](/problem/2625.md) | | <font color=#ffb800>Medium</font> |
1919
| 2626 | [数组归约运算](https://leetcode.com/problems/array-reduce-transformation) | [[]](/problem/2626.md) | | <font color=#15bd66>Easy</font> |
2020
| 2627 | [函数防抖](https://leetcode.com/problems/debounce) | [[]](/problem/2627.md) | | <font color=#ffb800>Medium</font> |

src/problem/0104.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ var maxDepth = function (root) {
9191
| 559 | [N 叉树的最大深度](https://leetcode.com/problems/maximum-depth-of-n-ary-tree) | [[]](/problem/0559.md) | [``](/tag/tree.md) [`深度优先搜索`](/tag/depth-first-search.md) [`广度优先搜索`](/tag/breadth-first-search.md) | <font color=#15bd66>Easy</font> |
9292
| 1376 | [通知所有员工所需的时间](https://leetcode.com/problems/time-needed-to-inform-all-employees) | | [``](/tag/tree.md) [`深度优先搜索`](/tag/depth-first-search.md) [`广度优先搜索`](/tag/breadth-first-search.md) | <font color=#ffb800>Medium</font> |
9393
| 2385 | [感染二叉树需要的总时间](https://leetcode.com/problems/amount-of-time-for-binary-tree-to-be-infected) | | [``](/tag/tree.md) [`深度优先搜索`](/tag/depth-first-search.md) [`广度优先搜索`](/tag/breadth-first-search.md) `2+` | <font color=#ffb800>Medium</font> |
94-
| 2458 | [移除子树后的二叉树高度](https://leetcode.com/problems/height-of-binary-tree-after-subtree-removal-queries) | | [``](/tag/tree.md) [`深度优先搜索`](/tag/depth-first-search.md) [`广度优先搜索`](/tag/breadth-first-search.md) `2+` | <font color=#ff334b>Hard</font> |
94+
| 2458 | [移除子树后的二叉树高度](https://leetcode.com/problems/height-of-binary-tree-after-subtree-removal-queries) | [[]](/problem/2458.md) | [``](/tag/tree.md) [`深度优先搜索`](/tag/depth-first-search.md) [`广度优先搜索`](/tag/breadth-first-search.md) `2+` | <font color=#ff334b>Hard</font> |

src/problem/0559.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ _Nary-Tree input serialization is represented in their level order traversal, ea
3434

3535
## 题目大意
3636

37+
给定一个 N 叉树,找到其最大深度。
38+
39+
最大深度是指从根节点到最远叶子节点的最长路径上的节点总数。
40+
41+
N 叉树输入按层序遍历序列化表示,每组子节点由空值分隔(请参见示例)。
42+
43+
## 解题思路
44+
3745
思路和 [第 104 题 二叉树的最大深度](./0104.md) 一样。
3846

3947
### 思路一:递归

0 commit comments

Comments
 (0)