File tree Expand file tree Collapse file tree 5 files changed +111
-1
lines changed Expand file tree Collapse file tree 5 files changed +111
-1
lines changed Original file line number Diff line number Diff line change 8282- [ day 23] ( ./day23.md )
8383 - [ 669. 修剪二叉搜索树] ( ./day23/lc669.md )
8484 - [ 108. 将有序数组转换为二叉搜索树] ( ./day23/lc108.md )
85- - [ 538. 把二叉搜索树转换为累加树] ( ./day23/lc538.md )
85+ - [ 538. 把二叉搜索树转换为累加树] ( ./day23/lc538.md )
86+ - [ day 24]
87+ - [ 77. 组合] ( ./day24/lc77.md )
88+ - [ 216. 组合总和 III] ( ./day24/lc216.md )
Original file line number Diff line number Diff line change 1+ # 第六章 二叉树part09
2+ 今日内容:
3+
4+ ● 669. 修剪二叉搜索树
5+ ● 108.将有序数组转换为二叉搜索树
6+ ● 538.把二叉搜索树转换为累加树
7+ ● 总结篇
8+
9+ 详细布置
10+
11+ ## 669. 修剪二叉搜索树
12+
13+ 这道题目比较难,比 添加增加和删除节点难的多,建议先看视频理解。
14+
15+ 题目链接/文章讲解: 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
16+ 视频讲解: https://www.bilibili.com/video/BV17P41177ud
17+
18+ ## 108.将有序数组转换为二叉搜索树
19+
20+ 本题就简单一些,可以尝试先自己做做。
21+
22+ 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
23+ 视频讲解:https://www.bilibili.com/video/BV1uR4y1X7qL
24+
25+ ## 538.把二叉搜索树转换为累加树
26+
27+ 本题也不难,在 求二叉搜索树的最小绝对差 和 众数 那两道题目 都讲过了 双指针法,思路是一样的。
28+
29+ 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
30+ 视频讲解:https://www.bilibili.com/video/BV1d44y1f7wP
31+ ## 总结篇
32+
33+ 好了,二叉树大家就这样刷完了,做一个总结吧
34+
35+ https://programmercarl.com/%E4%BA%8C%E5%8F%89%E6%A0%91%E6%80%BB%E7%BB%93%E7%AF%87.html
36+
37+
38+
Original file line number Diff line number Diff line change 1+ 虽然回溯法很难,很不好理解,但是回溯法并不是什么高效的算法。
2+
3+ 回溯法解决的问题都可以抽象为树形结构,是的,我指的是所有回溯法的问题都可以抽象为树形结构!
Original file line number Diff line number Diff line change 1+ # 216. 组合总和 III
2+
3+ ## 题目描述
4+
5+ 找出所有相加之和为 n 的 k 个数的组合,且满足下列条件:
6+
7+ 只使用数字1到9
8+ 每个数字 最多使用一次
9+ 返回 所有可能的有效组合的列表 。该列表不能包含相同的组合两次,组合可以以任何顺序返回。
10+
11+
12+ ## 解题思路
13+
14+
15+ ``` cpp
16+ class Solution {
17+ public:
18+ vector<vector<int >>res;
19+ vector<int >cur;
20+ int cursum=0;
21+ int k,n;
22+ void bt(int start){
23+ if(cur.size()==k&&cursum==n){res.push_back(cur);return;}
24+ for(int i=start;i<10&&cursum<n;i++){
25+ cur.push_back(i);cursum+=i;
26+ bt(i+1);
27+ cur.pop_back();cursum-=i;
28+ }
29+ }
30+ vector<vector<int >> combinationSum3(int k, int n) {
31+ this->k=k;this->n=n;bt(1);return res;
32+ }
33+ };
34+ ```
35+ ## 学习感想
Original file line number Diff line number Diff line change 1+ # 77. 组合
2+
3+ ## 题目描述
4+
5+ 给定两个整数 n 和 k,返回范围 [ 1, n] 中所有可能的 k 个数的组合。
6+
7+ 你可以按 任何顺序 返回答案。
8+
9+ ## 解题思路
10+
11+ ``` cpp
12+ class Solution {
13+ public:
14+ vector<vector<int >>res;
15+ vector<int >cur;
16+ int n,k;
17+ void bt(int start){
18+ if(cur.size()==k){res.push_back(cur);return;}
19+ for(int i=start;i<=n-(k-cur.size())+1;i++){
20+ cur.push_back(i);
21+ bt(i+1);
22+ cur.pop_back();
23+ }
24+ }
25+ vector<vector<int >> combine(int n, int k) {
26+ this->n=n;this->k=k;bt(1);return res;
27+ }
28+ };
29+ ```
30+
31+ ## 学习感想
You can’t perform that action at this time.
0 commit comments