这题目是经典的DP题目,也可叫作LIS(Longest Increasing Subsequence)最长上升子序列 或者 最长不下降子序列。很基础的题目,有两种算法,复杂度分别为O(n*logn)和O(n^2) 。A.O(n^2)算法分析如下:(a[1]...a[n] 存的都是输入的数)1、对于a...
分类:
编程语言 时间:
2015-01-07 18:26:49
阅读次数:
280
问题描述:
Given a string S and a string
T, count the number of distinct subsequences of T in
S.
A subsequence of a string is a new string which is formed from the original string by deleting some...
分类:
其他好文 时间:
2015-01-05 21:58:33
阅读次数:
185
Longest Common SubsequenceGiven two strings, find the longest comment subsequence (LCS).Your code should return the length of LCS.样例For "ABCD" and "ED...
分类:
其他好文 时间:
2015-01-03 15:55:06
阅读次数:
177
Common SubsequenceTime Limit: 2 SecMemory Limit: 64 MBSubmit: 951Solved: 374DescriptionA subsequence of a given sequence is the given sequence with so...
分类:
其他好文 时间:
2015-01-02 15:52:53
阅读次数:
112
题目:(DP)Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from t...
分类:
其他好文 时间:
2015-01-02 10:55:22
阅读次数:
120
Given two strings, find the longest comment subsequence (LCS).Your code should return the length of LCS.ExampleFor "ABCD" and "EDCA", the LCS is "A" (...
分类:
其他好文 时间:
2015-01-01 00:12:17
阅读次数:
122
Distinct SubsequencesGiven a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is...
分类:
其他好文 时间:
2014-12-31 20:03:18
阅读次数:
373
Given a sequence of integers, find the longest increasing subsequence (LIS).You code should return the length of the LIS.ExampleFor [5, 4, 1, 2, 3], t...
分类:
其他好文 时间:
2014-12-29 06:31:53
阅读次数:
131
Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig...
分类:
其他好文 时间:
2014-12-24 11:36:21
阅读次数:
173
解题思路:先注意到序列和串的区别,序列不需要连续,而串是需要连续的,先由样例abcfbc abfcab画一个表格分析,用dp[i][j]储存当比较到s1[i],s2[j]时最长公共子序列的长度 a b f c a b 0 0 0 0 0 0 0a 0 1 1 1 1 1 1b 0 1 2 2 2 2...
分类:
其他好文 时间:
2014-12-20 08:13:50
阅读次数:
187