Skip to content

Commit a582731

Browse files
author
xingdali
committed
添加题98
1 parent 0c36294 commit a582731

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

算法思维/二叉搜索树.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## 二叉搜索树
2+
3+
### 定义
4+
5+
- 每个节点中的值必须大于(或等于)存储在其左侧子树中的任何值。
6+
- 每个节点中的值必须小于(或等于)存储在其右子树中的任何值。
7+
8+
### 应用
9+
10+
##### [98. 验证二叉搜索树](https://leetcode-cn.com/problems/validate-binary-search-tree/)
11+
12+
```tsx
13+
function isValidBST(root: TreeNode | null): boolean {
14+
return helper(root, -Infinity, Infinity)
15+
};
16+
17+
function helper(node: TreeNode | null, lower: number, upper: number): boolean {
18+
if (node === null) {
19+
return true
20+
}
21+
if (node.val <= lower || node.val >= upper) {
22+
return false
23+
}
24+
return helper(node.left, lower, node.val) && helper(node.right, node.val, upper)
25+
}
26+
```
27+

算法思维/滑动窗口思想.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# 滑动窗口
1+
## 滑动窗口
22

3-
## 模板
3+
### 模板
44

55
```c++
66
/* 滑动窗口算法框架 */
@@ -42,7 +42,7 @@ void slidingWindow(string s, string t) {
4242
- 3、左指针右移之后窗口数据更新
4343
- 4、根据题意计算结果
4444
45-
## 示例
45+
### 示例
4646
4747
##### [76. 最小覆盖子串](https://leetcode-cn.com/problems/minimum-window-substring/)
4848
@@ -211,7 +211,7 @@ function lengthOfLongestSubstring(s: string): number {
211211
};
212212
```
213213

214-
## 总结
214+
### 总结
215215

216216
- 和双指针题目类似,更像双指针的升级版,滑动窗口核心点是维护一个窗口集,根据窗口集来进行处理
217217
- 核心步骤
@@ -220,7 +220,7 @@ function lengthOfLongestSubstring(s: string): number {
220220
- left 右移
221221
- 求结果
222222

223-
## 练习
223+
### 练习
224224

225225
- [minimum-window-substring](https://leetcode-cn.com/problems/minimum-window-substring/)
226226
- [permutation-in-string](https://leetcode-cn.com/problems/permutation-in-string/)

0 commit comments

Comments
 (0)