Maximum Depth of Binary TreeTotal Accepted:59837Total Submissions:132940My SubmissionsQuestionSolutionGiven a binary tree, find its maximum depth.The ...
分类:
其他好文 时间:
2015-04-14 16:09:07
阅读次数:
145
Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which rep...
分类:
其他好文 时间:
2015-04-14 14:25:32
阅读次数:
123
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 next smallest number in the BST.
Note: next() and...
分类:
其他好文 时间:
2015-04-14 13:01:30
阅读次数:
148
C++STL有好几种查找算法,但是他们的用法上有很多共同的地方:1、除了binary_search的返回值是bool之外(查找的了返回true,否则返回false),其他所有的查找算法返回值都是一个迭代器(查找成功返回目标所在迭代器的位置,否则返回最后一个元素的后一个位置或者说是容器的end())2...
分类:
编程语言 时间:
2015-04-14 12:51:00
阅读次数:
161
Same TreeTotal Accepted:56263Total Submissions:133912My SubmissionsQuestionSolutionGiven two binary trees, write a function to check if they are equal...
分类:
其他好文 时间:
2015-04-14 11:07:01
阅读次数:
110
Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.很简单的二分法,只要给...
分类:
编程语言 时间:
2015-04-14 07:09:13
阅读次数:
133
Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No...
分类:
其他好文 时间:
2015-04-14 00:30:05
阅读次数:
163
归并排序的数组实现 1 //折半插入排序 2 void insertSort_Binary(int *arr, int len) 3 { 4 int i, j;//工作指针 5 int low, mid, high;//折半查找指针 6 int current;//暂存待插入...
分类:
编程语言 时间:
2015-04-13 22:37:34
阅读次数:
129
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:
其他好文 时间:
2015-04-13 22:34:41
阅读次数:
141
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next...
分类:
其他好文 时间:
2015-04-13 20:42:55
阅读次数:
102