Given a binary tree, return the postorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [3,2,1].
Note: Recursive solut...
分类:
其他好文 时间:
2015-06-06 13:38:24
阅读次数:
138
Count Complete Tree NodesGiven acompletebinary tree, count the number of nodes.In a complete binary tree every level, except possibly the last, is com...
分类:
其他好文 时间:
2015-06-06 13:26:14
阅读次数:
105
题目描述
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example:
Given the below binary t...
分类:
其他好文 时间:
2015-06-06 12:10:56
阅读次数:
131
题目描述
Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.
For example:
Given the below binary tree and sum = 22, 5
/ \...
分类:
其他好文 时间:
2015-06-06 12:09:10
阅读次数:
117
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the ne...
分类:
编程语言 时间:
2015-06-06 11:55:56
阅读次数:
196
题目:http://community.topcoder.com/stat?c=problem_statement&pm=13275&rd=16008由于图中边数不多,选择DFS遍历全部路径,计算路径Inversions时使用了一个R[] 数组,能够在O(N)时间内得到路径Inversions,又由...
分类:
其他好文 时间:
2015-06-06 11:45:01
阅读次数:
96
LeetCode Contains Duplicate III题目思路我的方法是先用一个结构体,存下每个数字的值和其原坐标;
然后根据值大小排序;
接着遍历每一个数字num[i].val;
利用二分查找找到刚好比num[i].val - t - 1大的数字的坐标;
然后根据坐标判断是否存在值即可;
关于二分查找可见:Binary Search代码struct num {
int p...
分类:
其他好文 时间:
2015-06-06 09:09:47
阅读次数:
96
L102: Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example:
Given binary tree {3,9,20,#...
分类:
其他好文 时间:
2015-06-05 22:48:47
阅读次数:
140
Sum Root to Leaf NumbersTotal Accepted:45133Total Submissions:148808My SubmissionsQuestionSolutionGiven a binary tree containing digits from0-9only, e...
分类:
其他好文 时间:
2015-06-05 12:12:04
阅读次数:
93