longest incresing sequence
动态规划基本题目,longest incresing sequence,找出序列中的最长递增子序列;
例如给出序列{8,3,5,2,4,9,7,11},
其中最长递增子序列为{3,5,9,11}或{3,5,7,11}或{3,4,9,11}或{3,4,7,11},子序列按元素递增,序列长度都为4;
子问题:第i处的最长子序列问题
定义问题:
阶段:后序,到第i项为阶段i;
状态:到i处的最长子序列为dp[i];
决策:dp[i]=max{dp[j]}+1,i<j<=n,a[i]<a[j]
有了上述公式既可以建立动态表dp;
| Array | 8 | 3 | 5 | 2 | 4 | 9 | 7 | 11 |
| dp | 3 | 4 | 3 | 4 | 3 | 2 | 2 | 1 |
代码之后给出
longest incresing sequence的更多相关文章
- [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列
Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...
- [LeetCode] Longest Consecutive Sequence 求最长连续序列
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...
- Binary Tree Longest Consecutive Sequence
Given a binary tree, find the length of the longest consecutive sequence path (连续的路径,不是从小到大). The pa ...
- 128. Longest Consecutive Sequence(leetcode)
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...
- ACM Longest Repeated Sequence
Description You are given a sequence of integers, A = a1, a2, ... an. A consecutive subsequence of A ...
- [LintCode] Longest Consecutive Sequence 求最长连续序列
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. H ...
- LeetCode Binary Tree Longest Consecutive Sequence
原题链接在这里:https://leetcode.com/problems/binary-tree-longest-consecutive-sequence/ 题目: Given a binary t ...
- 24. Longest Consecutive Sequence
Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest con ...
- 【leetcode】Longest Consecutive Sequence
Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest con ...
随机推荐
- Centon6.5虚拟机桥接设置
参考资料:http://blog.csdn.net/iamfafa/article/details/6209009 安装虚拟机的时候 就直接选择桥接,可以直接 使用 查看此状态下的配置如下 : 虚拟环 ...
- U-Boot在FL2440上移植(三)----支持NAND Flash
<一>支持NAND Flash 1. 首先在配置文件 include/config/fl2440.h 的宏 CONFIG_COMMANDS 中增加 CFG_CMD_NAND, #defin ...
- Runtime.getRuntime().exec(...)使用方法
Runtime.getRuntime().exec(...)使用方法 如果想要了解更多的信息,参阅代码里面给的链接 下面是这个正确的例子 public class RuntimeExec { /** ...
- SQL查询各阶段的统计信息
我们经常会遇到各种分类统计问题,须要将这些结果一次显示出来.这次老师提出的要求是我想看60分下面多少人.60~70多少人,70~80多少人.80~90多少人,90~100多少人.他们曾 ...
- Arcgis for javascript map操作addLayer具体解释
本节的内容非常easy.说说Arcgis for Javascript里面map对象的addLayer方法.在for JS的API中,addLayer方法有两种.例如以下图: watermark/2/ ...
- 64位CentOS上编译 Hadoop 2.2.0
下载了Hadoop预编译好的二进制包,hadoop-2.2.0.tar.gz,启动起来后.总是出现这样的警告: WARN util.NativeCodeLoader: Unable to load n ...
- Android图片异步加载的方法
很多时候,我们在加载大图片或者需要处理较多图像数据的时候,希望显示效果能好点,不至于因为图片解码耗时产生ANR等情况,不得不说异步加载是个不错的方法.说到异步加载,避免application出现ANR ...
- java打印日历
打个日历,写了半天,感情水平真菜, 不过主要是不会数组,明天一定要把数组看了 package demo; import java.util.Scanner; public class Demo { / ...
- CentOS的MySQL报错:Can't connect to MySQL server
原文链接: http://www.centoscn.com/CentosBug/softbug/2015/0622/5709.html 问题描述: 使用客户端远程登录连接基于CentOS 6.5服务器 ...
- Windows(64位IIS)未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序
在Windows 7(32位)用.Net开发的Excel导入数据表功能,测试后一切正常,站点发布挪到Windows Server 2008(64位)上就意外了,出现错误提示,运行程序,抛出异常:未在本 ...