Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ainevsia committed Aug 3, 2023
1 parent 15178d4 commit 484a97f
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 1 deletion.
5 changes: 4 additions & 1 deletion notes/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,7 @@
- [day 23](./day23.md)
- [669. 修剪二叉搜索树](./day23/lc669.md)
- [108. 将有序数组转换为二叉搜索树](./day23/lc108.md)
- [538. 把二叉搜索树转换为累加树](./day23/lc538.md)
- [538. 把二叉搜索树转换为累加树](./day23/lc538.md)
- [day 24]
- [77. 组合](./day24/lc77.md)
- [216. 组合总和 III](./day24/lc216.md)
38 changes: 38 additions & 0 deletions notes/src/day23.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 第六章 二叉树part09
今日内容:

● 669. 修剪二叉搜索树
● 108.将有序数组转换为二叉搜索树
● 538.把二叉搜索树转换为累加树
● 总结篇

详细布置

## 669. 修剪二叉搜索树

这道题目比较难,比 添加增加和删除节点难的多,建议先看视频理解。

题目链接/文章讲解: https://programmercarl.com/0669.%E4%BF%AE%E5%89%AA%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91.html
视频讲解: https://www.bilibili.com/video/BV17P41177ud

## 108.将有序数组转换为二叉搜索树

本题就简单一些,可以尝试先自己做做。

https://programmercarl.com/0108.%E5%B0%86%E6%9C%89%E5%BA%8F%E6%95%B0%E7%BB%84%E8%BD%AC%E6%8D%A2%E4%B8%BA%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91.html
视频讲解:https://www.bilibili.com/video/BV1uR4y1X7qL

## 538.把二叉搜索树转换为累加树

本题也不难,在 求二叉搜索树的最小绝对差 和 众数 那两道题目 都讲过了 双指针法,思路是一样的。

https://programmercarl.com/0538.%E6%8A%8A%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E8%BD%AC%E6%8D%A2%E4%B8%BA%E7%B4%AF%E5%8A%A0%E6%A0%91.html
视频讲解:https://www.bilibili.com/video/BV1d44y1f7wP
## 总结篇

好了,二叉树大家就这样刷完了,做一个总结吧

https://programmercarl.com/%E4%BA%8C%E5%8F%89%E6%A0%91%E6%80%BB%E7%BB%93%E7%AF%87.html



3 changes: 3 additions & 0 deletions notes/src/day24.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
虽然回溯法很难,很不好理解,但是回溯法并不是什么高效的算法。

回溯法解决的问题都可以抽象为树形结构,是的,我指的是所有回溯法的问题都可以抽象为树形结构!
35 changes: 35 additions & 0 deletions notes/src/day24/lc216.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 216. 组合总和 III

## 题目描述

找出所有相加之和为 n 的 k 个数的组合,且满足下列条件:

只使用数字1到9
每个数字 最多使用一次
返回 所有可能的有效组合的列表 。该列表不能包含相同的组合两次,组合可以以任何顺序返回。


## 解题思路


```cpp
class Solution {
public:
vector<vector<int>>res;
vector<int>cur;
int cursum=0;
int k,n;
void bt(int start){
if(cur.size()==k&&cursum==n){res.push_back(cur);return;}
for(int i=start;i<10&&cursum<n;i++){
cur.push_back(i);cursum+=i;
bt(i+1);
cur.pop_back();cursum-=i;
}
}
vector<vector<int>> combinationSum3(int k, int n) {
this->k=k;this->n=n;bt(1);return res;
}
};
```
## 学习感想
31 changes: 31 additions & 0 deletions notes/src/day24/lc77.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 77. 组合

## 题目描述

给定两个整数 n 和 k,返回范围 [1, n] 中所有可能的 k 个数的组合。

你可以按 任何顺序 返回答案。

## 解题思路

```cpp
class Solution {
public:
vector<vector<int>>res;
vector<int>cur;
int n,k;
void bt(int start){
if(cur.size()==k){res.push_back(cur);return;}
for(int i=start;i<=n-(k-cur.size())+1;i++){
cur.push_back(i);
bt(i+1);
cur.pop_back();
}
}
vector<vector<int>> combine(int n, int k) {
this->n=n;this->k=k;bt(1);return res;
}
};
```
## 学习感想

0 comments on commit 484a97f

Please sign in to comment.