Sum Root to Leaf NumbersGiven a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-l...
分类:
其他好文 时间:
2014-08-16 00:59:09
阅读次数:
197
Unique Binary Search Trees IIGivenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your pr...
分类:
其他好文 时间:
2014-08-15 23:44:29
阅读次数:
280
Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.
Recover the tree without changing its structure.
Note:
A solution using O(n)
space is pretty s...
分类:
其他好文 时间:
2014-08-15 19:39:39
阅读次数:
222
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.参考“Largest Rectangle in Histogram...
分类:
其他好文 时间:
2014-08-15 12:45:58
阅读次数:
162
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil...
分类:
其他好文 时间:
2014-08-15 12:07:08
阅读次数:
145
Problem Description:
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1
/ 2 5
/ \ 3 4 6
The flattened tree sho...
分类:
其他好文 时间:
2014-08-15 10:43:28
阅读次数:
198
1、折半查找 1 // 递归算法 2 int BinarySearch(int item, Node *elem, int left, int right) 3 { 4 int mid = -1; 5 if(left item)10 mid = Binary...
分类:
其他好文 时间:
2014-08-14 23:06:56
阅读次数:
241
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ...
分类:
其他好文 时间:
2014-08-14 20:20:09
阅读次数:
206
Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni...
分类:
其他好文 时间:
2014-08-14 20:16:29
阅读次数:
219
标准的二分查找:binary_search int bsearch(int a[],int l,int r,int x){ int m; while(l>2; if(a[m]==x) return m; else if(a[m]>x) r = m-1; else l ...
分类:
其他好文 时间:
2014-08-14 19:33:59
阅读次数:
226