题意: 平衡树定义为“一个整数的某个数位若是奇数,则该奇数必定出现偶数次;偶数位则必须出现奇数次”,比如 222,数位为偶数2,共出现3次,是奇数次,所以合法。给一个区间[L,R],问有多少个平衡数?思路: 这题比较好解决,只有前导零问题需要解决。如果枚举到011,那么其前导零(偶数)出现了1次.....
分类:
其他好文 时间:
2015-10-05 19:29:51
阅读次数:
182
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-10-04 12:20:39
阅读次数:
174
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.struct ListNode { int val; ListNode *...
分类:
其他好文 时间:
2015-10-03 15:30:38
阅读次数:
152
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:使用二分法,将list的中间节点作为根节点,然后分别处理list左半边及右半边,以此递归。struc...
分类:
其他好文 时间:
2015-10-03 14:24:21
阅读次数:
162
Description:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.给一个升序有序的数组,构建一个平衡的二叉查找树。要平衡就要找中间的数来做头结点,递...
分类:
其他好文 时间:
2015-10-01 17:56:49
阅读次数:
132
原地址:http://blog.csdn.net/gzj_1101/article/details/48165873 B-tree树即B树,B即Balanced,平衡的意思。因为B树的原英文名称为B-tree,而国内很多人喜欢把B-tree译作B-树,其实,这是个非常不好的直译,很容易让人产生误解。...
分类:
其他好文 时间:
2015-09-23 23:10:13
阅读次数:
325
If you have 2 level 25 pets and any level 1 pet, obviously start with him in your lineup.Defeat all eastern kingdoms pet trainers in order of level (d...
分类:
其他好文 时间:
2015-09-20 22:07:22
阅读次数:
165
很明显是一道RMQ问题,倍增法,维护一下区域的最大/小值就行了。 1 var n,i,j,q,f,t,times:longint; 2 hmin,hmax:array[0..100,0..50000] of longint; 3 function min(a,b:longint):longint; ...
分类:
其他好文 时间:
2015-09-18 13:27:32
阅读次数:
155
1636: [Usaco2007 Jan]Balanced LineupTime Limit: 5 SecMemory Limit: 64 MBSubmit: 599Solved: 423[Submit][Status][Discuss]DescriptionFor the daily milkin...
分类:
其他好文 时间:
2015-09-16 21:56:57
阅读次数:
265
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-09-16 06:19:09
阅读次数:
140