题目:
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1
/ 2 5
/ \ 3 4 6
The flattened tree should look like:
...
分类:
编程语言 时间:
2015-01-16 20:58:36
阅读次数:
159
题目:Given an array where elements are sorted in ascending order, convert it to a height balanced
BST.
思路:给出一个排序的数组,如何构造一个平衡二叉查找树?平衡二叉查找树要求任一结点的左右子树的高度差不能超过一,也叫做高度平衡树。如果让我们从一个排序数组中选取一个元素做树的根,我们会选择哪一个...
分类:
编程语言 时间:
2015-01-16 16:51:25
阅读次数:
237
题目:
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent
a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Find...
分类:
编程语言 时间:
2015-01-14 22:59:16
阅读次数:
431
题目:
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-01-12 19:24:15
阅读次数:
170
题目:
Given two binary trees, write a function to check if they are equal or not.
Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
Ans...
分类:
编程语言 时间:
2015-01-12 16:44:08
阅读次数:
216
题目:
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 tree a...
分类:
编程语言 时间:
2015-01-12 16:40:36
阅读次数:
221
计算树的深度1、minimum depth of binary tree 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * ...
分类:
其他好文 时间:
2014-07-07 15:31:40
阅读次数:
182