解法一:通过遍历得到(0:i)的LIS,时间复杂度O(N^2);具体思路于代码,如下: 1 #include 2 #include 3 using namespace std; 4 5 int longSub(int arr[],int n); 6 7 int main() 8 { 9 ...
分类:
其他好文 时间:
2014-08-20 15:44:12
阅读次数:
147
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-20 14:01:12
阅读次数:
184
题目:POJ 2533 Longest Ordered Subsequence
Description
A numeric sequence of ai is ordered if a1 a2 aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN)
be any sequence (ai1...
分类:
其他好文 时间:
2014-08-19 16:37:44
阅读次数:
218
点击打开链接题目链接
1110 - An Easy LCS
PDF (English)
Statistics
Forum
Time Limit: 2 second(s)
Memory Limit: 32 MB
LCS means 'Longest Common Subsequence' that means ...
分类:
其他好文 时间:
2014-08-19 12:59:35
阅读次数:
604
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
Description
Given an undirected weighted graph G, you should find one of spanning trees specified as follows.
The graph G is an ordered pair (V, E), where V is a set of vertices {v1, v2, …, vn}
...
分类:
其他好文 时间:
2014-08-15 09:33:57
阅读次数:
259