题意 给出至多1e5个长度不超过1e5的括号序列,问将他们排序重组后最多能有多少对合法括号 思路 先将已经匹配的括号全部去掉,然后我们的序列就只会剩下三种形式——$"((((("$,$"))))((("$,$"))))"$,然后这时候就只有序列的左右括号的数量起作用了,所以我们只需通过这个条件来对他 ...
分类:
其他好文 时间:
2018-12-11 18:43:14
阅读次数:
180
AVL树或者是一棵空树,或者是具有以下性质的非空二叉搜索树: 1. 任一结点的左、右子树均为AVL树; 2.根结点左、右子树高度差的绝对值不超过1. 1.声明 #include<iostream> #include<cstdio> #include<queue> using namespace st ...
分类:
其他好文 时间:
2018-12-08 17:52:19
阅读次数:
203
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 dep ...
分类:
其他好文 时间:
2018-11-27 13:42:22
阅读次数:
140
Description Farmer John 决定给他的奶牛们照一张合影,他让 N (1 ≤ N ≤ 50,000) 头奶牛站成一条直线,每头牛都有它的 坐标(范围: 0..1,000,000,000)和种族(0或1)。 一直以来 Farmer John 总是喜欢做一些非凡的事,当然这次照相 也不 ...
分类:
其他好文 时间:
2018-11-24 18:50:42
阅读次数:
163
1. 二叉搜索树 二叉搜索树,是一种能实现动态查询第k大或查询,某数在序列中的排名的树形结构,在数据较为随机的情况下,它的期望复杂度为O(logn),但是若是数据为一个有序序列,那么该二叉搜索树,将会变成一条链,此时每次查找的复杂度将会变成复杂度为O(n) 2. SBT 针对上述问题,为了能使复杂度 ...
分类:
其他好文 时间:
2018-11-20 23:00:36
阅读次数:
156
There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties: (1) Every node is either ...
分类:
其他好文 时间:
2018-11-17 11:52:08
阅读次数:
142
AVL Tree An AVL tree is a kind of balanced binary search tree. Named after their inventors, Adelson-Velskii and Landis, they were the first dynamicall ...
分类:
其他好文 时间:
2018-11-01 11:48:10
阅读次数:
132
题目链接:传送门 题目: 题目描述 Farmer John has decided to assemble a panoramic photo of a lineup of his N cows (1 <= N <= 200,000), which, as always, are convenien ...
分类:
其他好文 时间:
2018-10-31 23:26:05
阅读次数:
248
题目大意是:一个农夫有N头牛,每头牛的高度不同,让你找出指定区间最高牛和最低牛的高度差。 解题思路: 一看到题目就想到了线段树,然后用了递归的线段树,一开始一直TLE,本来想换成非递归版本,后来输入输出优化了一下就A了,这让我感受到了优化的妙处!!! 非递归版可以去看看这篇文章了解下:https:/ ...
分类:
其他好文 时间:
2018-10-27 11:58:44
阅读次数:
148