判断一棵树是不是平衡二叉树,之前做过,还有点印象,用一个函数返回树的高度,如果是-1的话,就说明子树不平衡。1A很开心~ 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * T...
分类:
其他好文 时间:
2014-07-07 13:56:05
阅读次数:
180
Problem Description:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tre...
分类:
其他好文 时间:
2014-07-07 13:27:35
阅读次数:
207
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
分类:
其他好文 时间:
2014-07-03 19:10:40
阅读次数:
201
Given a binary tree, determine if it is height-balanced.
分类:
其他好文 时间:
2014-07-03 19:00:17
阅读次数:
188
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
分类:
其他好文 时间:
2014-07-03 18:55:48
阅读次数:
236
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth...
分类:
其他好文 时间:
2014-06-28 10:07:19
阅读次数:
208
DescriptionFor the daily milking, Farmer John'sNcows (1 ≤N≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game o...
分类:
其他好文 时间:
2014-06-28 09:32:17
阅读次数:
200
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.TreeNode *createSearchTree(ListNode *&hea...
分类:
其他好文 时间:
2014-06-26 00:12:57
阅读次数:
289
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(...
分类:
其他好文 时间:
2014-06-24 13:32:40
阅读次数:
157
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.说明:平衡二叉搜索树,即任何结点的左子树和右子树高度最多相差1的二叉搜索树。二叉搜索树:二叉查找树(Bin...
分类:
其他好文 时间:
2014-06-21 00:47:08
阅读次数:
221