首页
学习
活动
专区
工具
TVP
发布

Linux云计算网络

专栏之后会专注云计算领域,欢迎关注我的公众号 Linux云计算网络,第一时间见到干货
专栏成员
178
文章
311093
阅读量
115
订阅数
LeetCode:105_Construct Binary Tree from Preorder and Inorder Traversal | 根据前序和中序遍历构建二叉树 | Medium
要求:通过二叉树的前序和中序遍历序列构建一颗二叉树 代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode *left; 4 TreeNode *right; 5 TreeNode(int x): val(x),left(NULL), right(NULL) {} 6 }; 7 8 typedef vector<int>::iterator Iter; 9 TreeNode *bui
Linux云计算网络
2018-01-11
4370
LeetCode: 106_Construct Binary Tree from Inorder and Postorder Traversal | 根据中序和后序遍历构建二叉树 | Medium
要求:根据中序和后序遍历序列构建一棵二叉树 代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode *left; 4 TreeNode *right; 5 TreeNode(int x): val(x),left(NULL), right(NULL) {} 6 }; 7 8 typedef vector<int>::iterator Iter; 9 10 TreeNode *bui
Linux云计算网络
2018-01-11
5430
LeetCode:110_Balanced Binary Tree | 平衡二叉树 | Easy
要求:判断一棵树是否是平衡二叉树 Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1. 代码如下: 1 struct TreeNo
Linux云计算网络
2018-01-11
5440
LeetCode:111_Minimum Depth of Binary Tree | 二叉树的最小深度 | Easy
要求:此题正好和Maximum Depth of Binary Tree一题是相反的,即寻找二叉树的最小的深度值:从根节点到最近的叶子节点的距离。 结题思路:和找最大距离不同之处在于:找最小距离要注意
Linux云计算网络
2018-01-11
6140
LeetCode:104_Maximum Depth of Binary Tree | 二叉树的最大深度 | Easy
要求:求二叉树的深度(二叉树的深度为最远叶子节点到根节点的距离,即根节点到最远叶子节点的距离) Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 有两种求解的思路,一种采用DFS的思想,一种采用BFS的思想,如下代码所示: 1 struc
Linux云计算网络
2018-01-11
6700
LeetCode:114_Flatten Binary Tree to Linked List | 将一棵二叉树变成链表的形式 | Medium
要求:Given a binary tree, flatten it to a linked list in-place.将二叉树转化为平坦序列的树。比如: 结题思路: 该题有个提示,转化后的树的序列
Linux云计算网络
2018-01-11
6170
LeetCode:145_Binary Tree Postorder Traversal | 二叉树后序遍历 | Hard
题目:Binary Tree Postorder Traversal 二叉树的后序遍历,题目要求是采用非递归的方式,这个在上数据结构的课时已经很清楚了,二叉树的非递归遍历不管采用何种方式,都需要用到栈结构作为中转,代码很简单,见下: 1 struct TreeNode { 2 int val; 3 TreeNode* left; 4 TreeNode* right; 5 TreeNode(int x): val(x), left(N
Linux云计算网络
2018-01-11
4500
LeetCode:144_Binary Tree Preorder Traversal | 二叉树的前序遍历 | Medium
题目:Binary Tree Preorder Traversal 二叉树的前序遍历,同样使用栈来解,代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode* left; 4 TreeNode* right; 5 TreeNode(int x): val(x), left(NULL),right(NULL) {} 6 }; 7 8 vector<int> preorderTravers
Linux云计算网络
2018-01-11
4830
LeetCode:94_Binary Tree Inorder Traversal | 二叉树中序遍历 | Medium
题目:Binary Tree Inorder Traversal 二叉树的中序遍历,和前序、中序一样的处理方式,代码见下: 1 struct TreeNode { 2 int val; 3 TreeNode* left; 4 TreeNode* right; 5 TreeNode(int x): val(x), left(NULL),right(NULL) {} 6 }; 7 8 vector<int> preorderTr
Linux云计算网络
2018-01-11
4500
没有更多了
社区活动
【纪录片】中国数据库前世今生
穿越半个世纪,探寻中国数据库50年的发展历程
Python精品学习库
代码在线跑,知识轻松学
博客搬家 | 分享价值百万资源包
自行/邀约他人一键搬运博客,速成社区影响力并领取好礼
技术创作特训营·精选知识专栏
往期视频·千货材料·成员作品 最新动态
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档