hdu题目poj题目参考了罗穗骞的论文《后缀数组——处理字符串的有力工具》题意:求两个序列的最长公共子串思路:后缀数组经典题目之一(模版题)//后缀数组sa:将s的n个后缀从小到大排序后将 排序后的后缀的开头位置 顺次放入sa中,则sa[i]储存的是排第i大的后缀的开头位置。简单的记忆就是“排第几的...
分类:
其他好文 时间:
2014-08-18 23:24:13
阅读次数:
367
leetcode中和括号匹配相关的问题共有三个,分别是:
Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']',
determine if the input string is valid.
The brackets m...
分类:
其他好文 时间:
2014-08-18 20:35:52
阅读次数:
221
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le...
分类:
其他好文 时间:
2014-08-17 16:55:02
阅读次数:
202
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
最长公共子序列
时间限制:3000 ms | 内存限制:65535 KB
难度:3
描述
咱们就不拐弯抹角了,如题,需要你做的就是写一个程序,得出最长公共子序列。
tip:最长公共子序列也称作最长公共子串(不要求连续),英文缩写为LCS(Longest Common Subsequence)。其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合...
分类:
其他好文 时间:
2014-08-15 00:05:56
阅读次数:
335
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest...
分类:
其他好文 时间:
2014-08-13 21:50:47
阅读次数:
318
class Solution {public: int longestValidParentheses(string s) { vector stack; int maxlen = 0; int curlen = 0; int last ...
分类:
其他好文 时间:
2014-08-12 12:54:04
阅读次数:
169
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ...
分类:
其他好文 时间:
2014-08-10 15:33:50
阅读次数:
166
LCS!~如果你在百度上搜这个的话会出来”英雄联盟冠军联赛”,orz。。但是今天要讲的LCS是最长公共子序列 ,"Longest Common Subsequence "not"League of Legends Championship Series"小盆友们又要涨姿势了~ 最长公共子序列也称作最...
分类:
其他好文 时间:
2014-08-07 18:46:50
阅读次数:
271