这可能是一个很长的blog…… # from https://blog.csdn.net/justheretobe/article/details/51764587 #!/usr/bin/env python3 # -*- coding: utf-8 -*- def lcs(s1,s2): m = len(s1) n = len(s2) counter = [[0]*(n+1) for x in range(m+1)] longest = 0 lcs_set = set() for i in r
最长上升子序列,问题定义:http://blog.csdn.net/chenwenshi/article/details/6027086 代码: public static void getData( char[] L ) { int len = L.length; int[] f = new int[len]; String[] res = new String[len]; ; i < len; i++ ) { f[i] = ; res[i] = "" + L[i]; ; j
Alignment Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 14486 Accepted: 4695 Description In the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of the cap
题意:对于一个序列,要求去掉正好K个数字,若能使其成为不上升子序列或不下降子序列,则“A is a magic array.”,否则"A is not a magic array.\n". 分析: 1.求一遍LCS,然后在将序列逆转,求一遍LCS,分别可得最长上升子序列和最长下降子序列的长度tmp1.tmp2. 2.n - tmp1 <= k或n - tmp2 <= k即可,需要去掉的去完之后,在已经是最长上升或最长下降的序列中随便去够k个就好了. #include<
题目描述与背景介绍 背景题目: [674. 最长连续递增序列]https://leetcode-cn.com/problems/longest-continuous-increasing-subsequence/ [300. 最长递增子序列]https://leetcode-cn.com/problems/longest-increasing-subsequence/ 这两个都是DP的经典题目,674比较简单. 代码: class Solution { public int findLength
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=74662#problem/C A B C D E C - Largest Rectangle in a Histogram Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Practice UVA 111 Description Background Many