Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Not...
分类:
其他好文 时间:
2014-12-05 17:07:57
阅读次数:
179
One: Using two stacks, stack to traversal the node, stackr to record the parent node when visiting its right-child; https://oj.leetcode.com/problems.....
分类:
其他好文 时间:
2014-12-05 00:30:18
阅读次数:
158
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
简单的思想:正序排列时,某节点的右节点一定是该节点的右子树,中序排列,某节点的左节点一定是该节点的左子树;
...
分类:
其他好文 时间:
2014-12-04 18:03:12
阅读次数:
143
Binary Tree Inorder TraversalGiven a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3...
分类:
其他好文 时间:
2014-12-04 00:52:08
阅读次数:
191
Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 ...
分类:
其他好文 时间:
2014-12-03 23:14:20
阅读次数:
163
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
这类问题非常适合用递归做,递归思路如下:
前序遍历的第一个节点必然是根节点,中序遍历中根节点之前的节...
分类:
其他好文 时间:
2014-12-03 21:27:24
阅读次数:
172
Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa...
分类:
其他好文 时间:
2014-12-03 21:09:03
阅读次数:
119
Binary Tree Inorder TraversalGiven a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ...
分类:
其他好文 时间:
2014-12-02 22:10:23
阅读次数:
138
题目描述:
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 alternate between).
For example:
Gi...
分类:
其他好文 时间:
2014-12-01 10:12:10
阅读次数:
207
Construct Binary Tree from Preorder and Inorder TraversalGiven preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume...
分类:
其他好文 时间:
2014-11-30 16:46:40
阅读次数:
150