原题链接:点击此处 解题思路: 详情可见,算法竞赛入门经典(刘汝佳的那本紫书)第二版275页。 dp(i,j)表示的是A1,A2,A3....,Ai和B1,B2,B3...Bj的最长公共子序列(LCS)的长度。 当A[i]=B[i]时,dp(i,j)=d(i-1,j-1)+1; 否则dp(i,j)= ...
分类:
其他好文 时间:
2016-08-13 12:35:03
阅读次数:
129
Given a sequence of integers, find the longest increasing subsequence (LIS). You code should return the length of the LIS. Clarification What's the de ...
分类:
其他好文 时间:
2016-08-13 06:35:11
阅读次数:
361
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159 题目大意:给定两个字符串,求出两个字符串最大公共字符串。 一开始的话是没有什么思路的,后来除了借鉴书上p275《算法竞赛—入门经典》和某位博主的详细讲解,才算是明白了 借鉴链接:http://bl ...
分类:
其他好文 时间:
2016-08-12 23:28:09
阅读次数:
141
Problem Description A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ...
分类:
其他好文 时间:
2016-08-12 19:51:57
阅读次数:
141
Description Peter has a sequence and he define a function on the sequence -- , where is the length of the longest increasing subsequence ending with . ...
分类:
其他好文 时间:
2016-08-12 19:44:17
阅读次数:
213
Description A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm ...
分类:
其他好文 时间:
2016-08-10 22:19:15
阅读次数:
216
链接:https://leetcode.com/problems/wiggle-subsequence/ 解题思路:其实只需要比较a[n+1]-a[n]和a[n]-a[n-1]的正负性即可,定义变量flag记录上一次的正负性,current记录上一个的值,count记录满足要求的总和,于是有以下代码 ...
分类:
其他好文 时间:
2016-08-10 20:56:48
阅读次数:
307
C - Common Subsequence Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u C - Common Subsequence Description A subsequence of a give ...
分类:
其他好文 时间:
2016-08-08 21:04:16
阅读次数:
229
Subsequence Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12311 Accepted: 5169 Description A sequence of N positive integers (10 < N < 10 ...
分类:
其他好文 时间:
2016-08-08 17:22:44
阅读次数:
106
376. Wiggle Subsequence 376. Wiggle Subsequence Total Accepted: 5157 Total Submissions: 14616 Difficulty: Medium A sequence of numbers is called a wig ...
分类:
其他好文 时间:
2016-08-07 16:51:15
阅读次数:
113