题目描述
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 of the two subtrees of every node n...
分类:
其他好文 时间:
2015-05-04 12:06:20
阅读次数:
96
13 Red-black Trees Red-black trees are one of many search-tree schemes that are "balanced" in order to guarantee that basic dynamic-set operations tak...
分类:
其他好文 时间:
2015-05-04 11:46:23
阅读次数:
187
很基础的一道线段树的题,有个地方卡了我好久,我下面的这个代码所求的区间是左闭右开的,所以如果所求区间包括区间端点的话需要在有区间上+1
线段树是一种高效的数据结构,特点是求一个区间里的最小、最大值。 数据结构感觉像模板,但是其中的思想应该更值得我们学习,不过话说现在也没几个人能静下心去研究它的原理了吧。。
#include
#include
#include
#include
#in...
分类:
其他好文 时间:
2015-05-03 12:04:21
阅读次数:
141
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 of the two subtrees of every node never differ by more than 1....
分类:
其他好文 时间:
2015-05-01 17:25:28
阅读次数:
115
Time Limit: 5000MS
Memory Limit: 65536K
Total Submissions: 37683
Accepted: 17656
Case Time Limit: 2000MS
Description
For the daily milking, Farmer John's N cows (1 ≤ N ≤ ...
分类:
其他好文 时间:
2015-04-29 17:17:38
阅读次数:
139
题目链接:http://poj.org/problem?id=3264
题目大意:n个数,求区间[ L,R ]的最大最小值之差;
题目分析:
RQM:dp[ i ][ j ], i开始长度为2^j的长度的区间最值;
O(nlog n)的预处理区间值,O(1)的查询;
代码:
//author: ACsorry
//result: accept
#include
#inclu...
分类:
其他好文 时间:
2015-04-28 22:56:11
阅读次数:
156
Balanced Numbers
Time Limit:123MS Memory Limit:1572864KB 64bit IO Format:%lld
& %llu
Submit Status Practice SPOJ
BALNUM
Description
Balanced numbers have been used by mathe...
分类:
其他好文 时间:
2015-04-28 09:57:28
阅读次数:
174
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...
分类:
其他好文 时间:
2015-04-26 16:31:44
阅读次数:
119
Balanced Number
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 2640 Accepted Submission(s): 1196
Problem Description
A balance...
分类:
其他好文 时间:
2015-04-24 09:20:38
阅读次数:
151
判断一棵树是否是平衡树。平衡数的意思是,树左右子树高度之差不能超过1.【思路】递归判断每个子树是否是平衡数,需要调用高度计算的函数。【my code】bool isBalanced(TreeNode *root) { if(root==NULL) return t...
分类:
其他好文 时间:
2015-04-23 17:17:21
阅读次数:
181