Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 题目标签:Array, T ...
分类:
其他好文 时间:
2017-08-27 10:01:19
阅读次数:
107
105. Construct Binary Tree from Preorder and Inorder Traversal Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may ...
分类:
其他好文 时间:
2017-08-26 04:43:07
阅读次数:
152
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and ...
分类:
其他好文 时间:
2017-08-20 22:27:37
阅读次数:
129
递归解法: 从先序遍历中得到树的根节点,从中序遍历中得到左右数的组成节点。 更好理解的解法: ...
分类:
其他好文 时间:
2017-08-19 11:05:37
阅读次数:
130
Write a function to print spiral order traversal of a binary tree. For below tree, function should print 1, 2, 3, 4, 5, 6, 7. Solution. For a normal l ...
分类:
其他好文 时间:
2017-08-18 14:30:31
阅读次数:
136
LeetCode解题之Binary Tree Inorder Traversal 原题 不用递归来实现树的中序遍历。 注意点: 无 样例: 输入: {1,#,2,3} 1 \ 2 / 3 输出: [1,3,2] 解题思路 通过栈来实现,从根节点開始,不断寻找左节点,并把这些节点依次压入栈内。仅仅有在 ...
分类:
其他好文 时间:
2017-08-18 11:07:02
阅读次数:
138
问题: Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree{1,#,2,3}, return[1,2,3]. 递归方法: 非递归方法(利用栈): ...
分类:
其他好文 时间:
2017-08-18 11:06:35
阅读次数:
118
LeetCode解题之Binary Tree Zigzag Level Order Traversal 原题 实现树的弯曲遍历,即奇数层从左到右遍历。偶数层从右到左遍历。 注意点: 无 样例: 输入: 3 / \ 9 20 / \ 15 7 输出: [ [3], [20,9], [15,7] ] 解 ...
分类:
其他好文 时间:
2017-08-15 18:52:09
阅读次数:
122
参考:https://www.liuchuo.net/archives/2155,牛逼的同志,此致敬礼 #include <iostream>#include <vector>using namespace std;vector<int> post;vector<int> pre;bool isMi ...
分类:
其他好文 时间:
2017-08-15 12:00:48
阅读次数:
111
题目原文: Design an algorithm to perform an inorder traversal of a binary search tree using only a constant amount of extra space. 1 public void traverse( ...
分类:
其他好文 时间:
2017-08-14 19:00:13
阅读次数:
202