上一页 1 ··· 74 75 76 77 78 79 80 81 82 ··· 171 下一页
摘要: 题目传送门 一、样例解读 二、C++代码 #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, m; string s; //2^n长度的01串 /** * 功能:获取字符串s的类型 * @param 阅读全文
posted @ 2021-08-05 09:31 糖豆爸爸 阅读(316) 评论(0) 推荐(0)
摘要: 题目传送门 一、总结与感悟 1、二叉树遍历的代码模板 const int N = 1e6 + 10; //树的结构体+存储数组 //此处:为二叉树的标准创建、遍历模板,可用于其它试题! struct Node { int id; // 当前结点ID int left; // 左结点ID int ri 阅读全文
posted @ 2021-08-05 08:12 糖豆爸爸 阅读(95) 评论(0) 推荐(0)
摘要: 题目传送门 一、已知后序+中序,求前序 https://www.cnblogs.com/littlehb/p/15088998.html 二、已知前序+中序,求后序 https://www.cnblogs.com/littlehb/p/15088448.html 三、已知前序+后序,求中序个数 只有 阅读全文
posted @ 2021-08-04 17:09 糖豆爸爸 阅读(160) 评论(0) 推荐(0)
摘要: 一、数字全排列 小哈面前有三个箱子,手上有1,2,3三张牌,规定能放小牌就放小牌,小哈放完最后一个箱子后,最后在箱子的牌能有几种排列? 二、代码实现 #include <bits/stdc++.h> using namespace std; const int N = 10; int a[N]; b 阅读全文
posted @ 2021-08-03 15:38 糖豆爸爸 阅读(150) 评论(0) 推荐(0)
摘要: 题目传送门 一、二叉树+bfs解法 #include <bits/stdc++.h> using namespace std; typedef pair<int, int> PII; const int N = 210; bool st[N]; //是不是走过了 int n, ans = 0x3f3 阅读全文
posted @ 2021-08-02 15:40 糖豆爸爸 阅读(101) 评论(0) 推荐(0)
摘要: 题目传送门 一、数组+lower_bound+upper_bound模拟 #include <bits/stdc++.h> using namespace std; const int N = 10010; int a[N]; int q, cmd, number, cnt; long long p 阅读全文
posted @ 2021-08-02 14:01 糖豆爸爸 阅读(259) 评论(0) 推荐(0)
摘要: 二叉树的三种遍历方式 一、二叉树的前序、中序、后序遍历 二叉树遍历分为三种:前序、中序、后序,其中序遍历最为重要。为啥叫这个名字?是根据根节点的顺序命名的。 规则: 前中后序是对根而言的,前就是先说根是啥,中就是中间说根是啥,后是最后说根是啥。 除根以外,其它同级节点的遍历顺序是先左后右。 举栗子: 阅读全文
posted @ 2021-08-02 11:14 糖豆爸爸 阅读(2678) 评论(0) 推荐(0)
摘要: 题目传送门 一、已知后序+中序,求前序 求解步骤: (1)后序遍历的字符串,尾字母是子树的根。 (2)在中序遍历字符串中找到“步骤1查找到的尾字母”,它的左边就是左子树,右边就是右子树,可以计算获得左子树长度$cnt=i-l2$。 (3)在后序遍历字符串中根据左子树长度,获取到左子树子串(\(l1 阅读全文
posted @ 2021-08-02 10:53 糖豆爸爸 阅读(1047) 评论(0) 推荐(1)
摘要: 题目传送门 一、已知前序+中序,求后序 (1)、二叉树的遍历,就是一个深度优先搜索的过程: 前序 const int N = 1e6 + 10; //树的结构体+存储数组 struct Node { int id; // 当前结点ID int left; // 左结点ID int right;// 阅读全文
posted @ 2021-08-02 08:23 糖豆爸爸 阅读(546) 评论(1) 推荐(2)
摘要: 题目传送门 C++代码 #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; //树的结构体+存储数组 struct Node { int left; // 左结点ID int right;// 右结点ID } t 阅读全文
posted @ 2021-07-30 11:59 糖豆爸爸 阅读(121) 评论(0) 推荐(0)
上一页 1 ··· 74 75 76 77 78 79 80 81 82 ··· 171 下一页
Live2D