HDU 3709 Balanced Number (数位DP)...
分类:
其他好文 时间:
2014-08-18 14:34:22
阅读次数:
200
Balanced Lineup
Time Limit: 5000MS
Memory Limit: 65536K
Total Submissions: 34488
Accepted: 16203
Case Time Limit: 2000MS
Description
For the daily milking, Farme...
分类:
其他好文 时间:
2014-08-18 10:51:03
阅读次数:
259
平衡二叉树(Balanced Binary Tree)是二叉查找树的一个进化体,也是第一个引入平衡概念的二叉树。1962年,G.M. Adelson-Velsky 和 E.M. Landis发明了这棵树,所以它又叫AVL树。平衡二叉树要求对于每一个节点来说,它的左右子树的高度之差不能超过1,如果.....
分类:
其他好文 时间:
2014-08-18 10:26:43
阅读次数:
187
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:取数组的中点为树的根,前半部分为左子树,后半部分为右子树。 1 class Solution { 2...
分类:
其他好文 时间:
2014-08-17 13:02:12
阅读次数:
210
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:使用两个指针分别以1、2的速度遍历链表,以定位出链表的中点,进而将链表分割成...
分类:
其他好文 时间:
2014-08-17 02:21:36
阅读次数:
246
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...
分类:
其他好文 时间:
2014-08-16 23:42:41
阅读次数:
165
Balanced LineupTime Limit:5000MSMemory Limit:65536KTotal Submissions:34306Accepted:16137Case Time Limit:2000MSDescriptionFor the daily milking, Farmer...
分类:
其他好文 时间:
2014-08-16 17:01:10
阅读次数:
237
Convert Sorted List to Binary Search TreeGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST....
分类:
其他好文 时间:
2014-08-16 12:19:20
阅读次数:
227
spoj1811LCS
问两个字符串最长公共子串。
做法很简单。匹配成功,则tl++,失败,从父指针回退,tl=t[now].len。
从这题可以清楚了解后缀自动机fa指针的性质:
指向一个状态,这个状态的接受串s[x..x+i]是与当前状态的接受串后缀s[j-i..j]匹配是最长的一个。
这里是不是发现了一个和KMP很像的性质?
KMP在失配时通过next数组回退,那么这...
分类:
其他好文 时间:
2014-08-15 21:11:29
阅读次数:
281
思路:也是n个串连接成一个串,中间用没出现过的字符隔开,然后求后缀数组。
因为是不重叠的,所以和POJ 1743判断一样,只不过这里是多个串,每个串都要判断里面的最长公共前缀有没有重叠,所以用数组存下来就得了,然后再判断。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#defi...
分类:
其他好文 时间:
2014-08-15 16:02:09
阅读次数:
194