1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 int n; 10 int main() 11 { 12 cin >> n; 13 14 vec... ...
分类:
其他好文 时间:
2019-08-08 13:11:23
阅读次数:
77
题目如下: Given two strings text1 and text2, return the length of their longest common subsequence. A subsequence of a string is a new string generated fr ...
分类:
其他好文 时间:
2019-08-06 14:01:01
阅读次数:
81
问题描述: 最长公共子序列。给定两个长度分别为M和N的字符串a和b,求既是a的子序列又是b的子序列的字符串长度最长是多少。 状态表示: f[i][j]表示前缀字串a[1~i]与b[1~j]的“最长公共子序列”的长度。 阶段划分: 已经处理的前缀长度(两个字符串中的位置,即一个二维坐标系) 转移方程: ...
分类:
其他好文 时间:
2019-08-04 19:36:48
阅读次数:
88
题目链接:https://ac.nowcoder.com/acm/contest/885/G 题意: 两个串,s t,求s的所有子串中大于 t 的数目 题解: dp[i][j] 表示 s的前i个,匹配 t 的前 j 个的种类数, 那么 if(s[i] == t[j]) dp[i][j] = dp[i ...
分类:
其他好文 时间:
2019-08-04 13:10:24
阅读次数:
81
Given a sequence of K integers { N?1??, N?2??, ..., N?K?? }. A continuous subsequence is defined to be { N?i??, N?i+1??, ..., N?j?? } where 1. The Max ...
分类:
其他好文 时间:
2019-08-03 11:06:46
阅读次数:
94
题目链接 题意:每次给出两个字母 和 只有这两个字母的原字符串的子序列,最后让你输出原字符串。 思路:先将字符转换为hash值,然后再转换成图,就是一个拓扑排序了,然后满足不了的情况有两种,一个是构造不了给出的n字符串大小,还有就是字母去重后多了。 ...
分类:
其他好文 时间:
2019-08-02 21:09:34
阅读次数:
131
最长回文子序列 题目链接 https://leetcode.com/problems/longest palindromic subsequence/ 给定一个字符串s,找到其中最长的回文子序列。可以假设s的最大长度为1000。 最长回文子序列和上一题最长回文子串的区别是,子串是字符串中连续的一个序 ...
分类:
其他好文 时间:
2019-07-31 10:58:45
阅读次数:
95
给定一个无序的整数数组,找到其中最长上升子序列的长度。 示例: 输入: [10,9,2,5,3,7,101,18] 输出: 4 解释: 最长的上升子序列是?[2,3,7,101],它的长度是 4。 方法1:时间复杂度n2,容易想到,记录数组中每个元素作为上升子序列最后一个元素的最大长度。 impor ...
分类:
其他好文 时间:
2019-07-30 12:49:58
阅读次数:
76
This is a problem from ZOJ 2432.To make it easyer,you just need output the length of the subsequence. InputEach sequence is described with M - its len ...
分类:
其他好文 时间:
2019-07-24 15:09:56
阅读次数:
132