B. Balanced Substring You are given a string s consisting only of characters 0 and 1. A substring [l,?r] of s is a string slsl?+?1sl?+?2... sr, and it ...
分类:
其他好文 时间:
2017-10-14 15:04:05
阅读次数:
206
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 dept ...
分类:
其他好文 时间:
2017-10-09 09:54:55
阅读次数:
128
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1637 题意: Farmer John 决定给他的奶牛们照一张合影,他让 N (1 ≤ N ≤ 50,000) 头奶牛站成一条直线,每头牛都有它的坐标x(0 <= x <= 10^9)和种族( ...
分类:
其他好文 时间:
2017-10-07 12:05:58
阅读次数:
231
题目链接:http://poj.org/problem?id=3264 题意:n个数,给定m个区间,求出每个区间内最大值和最小值之差 题解:区间最值问题,挺裸的一道题 ...
分类:
其他好文 时间:
2017-10-04 00:15:55
阅读次数:
156
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. ...
分类:
其他好文 时间:
2017-10-02 20:54:36
阅读次数:
133
Balanced Number Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Problem Description A balanced number is a non-negat ...
分类:
其他好文 时间:
2017-09-29 23:12:30
阅读次数:
411
平衡二叉树(Balanced Binary Tree)是二叉查找树的一个进化体,也是第一个引入平衡概念的二叉树。1962年,G.M. Adelson-Velsky 和 E.M. Landis发明了这棵树,所以它又叫AVL树。平衡二叉树要求对于每一个节点来说,它的左右子树的高度之差不能超过1,如果插入 ...
分类:
其他好文 时间:
2017-09-27 22:34:23
阅读次数:
248
【题意】给定n头牛,k个特色,给出每头牛拥有哪些特色的二进制对应数字,[i,j]平衡当且仅当第i~j头牛的所有特色数量都相等,求最长区间长度。 【算法】平衡树+数学转化 【题解】统计前缀和sum[i][j]表示前i头牛特色为j的数量,则区间i~j平衡需要满足: sum[j][1]-sum[i-1][ ...
分类:
其他好文 时间:
2017-09-27 16:07:42
阅读次数:
135
3126: [Usaco2013 Open]Photo Description Farmer John has decided to assemble a panoramic photo of a lineup of his N cows (1 <= N <= 200,000), which, as ...
分类:
其他好文 时间:
2017-09-21 20:59:30
阅读次数:
196
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 dept ...
分类:
其他好文 时间:
2017-09-20 00:34:58
阅读次数:
104