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-08-06 19:39:33
阅读次数:
124
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5659 题意: 你有一个只包含"(" 和 ")" 的串,每一个位置有个数值,这个数 ...
分类:
其他好文 时间:
2017-08-05 05:53:38
阅读次数:
148
Given a sorted array. Write a program that creates a Balanced Binary Search Tree using array elements. If there are n elements in array, then floor(n/ ...
分类:
其他好文 时间:
2017-08-04 01:13:11
阅读次数:
201
原题链接 题意:给出一个打乱顺序的序列,问是否能构造出一个括号匹配的字符串。每个数字为此前读取到的左括号数减去右括号数。 分析:有左括号开始构造,不够的话就找右括号。注意特殊情况待处理。详情看代码 ...
分类:
其他好文 时间:
2017-08-03 23:07:24
阅读次数:
144
题目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 题解: 和我上面一篇将有序链表转成二叉排序树中用哈希表解的方法是一样的。基本思路:链表中间那个节 ...
分类:
编程语言 时间:
2017-07-31 10:05:20
阅读次数:
174
题意:链接 方法:线段树 解析: 题意即题解。 多次询问区间最大值与最小值的差。显然直接上线段树或者rmq维护区间最值就可以。 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #def ...
分类:
其他好文 时间:
2017-07-30 13:50:09
阅读次数:
148
题目链接:http://poj.org/problem?id=3264 题目大意: 一个农夫有N头牛,每头牛的高度不同,我们需要找出最高的牛和最低的牛的高度差。 解题思路:经典 RMQ ...
分类:
其他好文 时间:
2017-07-28 14:07:26
阅读次数:
101
题目描述 Farmer John has decided to assemble a panoramic photo of a lineup of his N cows (1 <= N <= 200,000), which, as always, are conveniently numbered ...
分类:
其他好文 时间:
2017-07-26 18:05:03
阅读次数:
274
一、前人种树 博客:RMQ算法分析 博客:谈谈RMQ算法 博客:RMQ (Range Minimum/Maximum Query)算法 二、沙场练兵 题目:poj 3264 Balanced Lineup ...
分类:
编程语言 时间:
2017-07-26 09:44:01
阅读次数:
204
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 给定有序数组构造二叉搜索树。考虑到二叉搜索树的性质(中序遍历二叉搜索树可以得到一个排序好的数组) 构造的 ...
分类:
其他好文 时间:
2017-07-23 19:52:33
阅读次数:
155