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 ...
随机推荐
- 解决ASP.NET回传后div滚动条位置复位的问题
中心思想:用一个隐藏控件保存当前scorll值.回传回来后根据scrollTop的值,然后在Page_Load中重新设置scrollTop. 首先是为DIV添加一个 onscroll="ja ...
- javascript模块加载框架seajs详解
SeaJS是一个遵循commonJS规范的javascript模块加载框架,可以实现javascript的模块化开发和模块化加载(模块可按需加载或全部加载).SeaJS可以和jQuery完美集成,使用 ...
- orcad10.5启动加速
OrCAD不知道怎么滴,启动速度慢的让人崩溃!30秒算快的,有时候甚至几分钟,要么需要连续开N次才打开,苦啊!!经过网上无数文章的洗礼,无数次的尝试,终于得出一种特效方法! 原因:OrCAD启动时在电 ...
- 羊和汽车问题(或s三门问题(Monty Hall problem)亦称为蒙提霍尔问题)
三门问题(Monty Hall problem)亦称为蒙提霍尔问题.蒙特霍问题或蒙提霍尔悖论,大致出自美国的电视游戏节目Let's Make a Deal.问题名字来自该节目的主持人蒙提·霍尔(Mon ...
- css网页自适应-1
一."自适应网页设计"的概念 2010年,Ethan Marcotte提出了"自适应网页设计"(Responsive Web Design)这个名词,指可以自动 ...
- Python中函数式使用
对于链表来讲,有三个内置函数非常有用: filter(),map() 以及 reduce(). filter(function, sequence) 返回一个 sequence(序列),包括了给定序列 ...
- [Swust OJ 137]--波浪数(hash+波浪数构造)
题目链接:http://acm.swust.edu.cn/problem/137/ Time limit(ms): 1000 Memory limit(kb): 65535 Description ...
- BZOJ 1263: [SCOI2006]整数划分( 高精度 )
yy一下发现好像越小越好...分解成3*3*3*3……这种形式是最好的...然后就是高精度了 ----------------------------------------------------- ...
- ssh "openssh-daemon is stopped"操作之伤+sftp访问“-bash: /dev/null: Permission denied”
1.ssh "openssh-daemon is stopped"操作之伤 原来好好的 sshd服务突然发现 不能重新启动了: [root@bogon rules.d]# ser ...
- vmware时间不同步的问题
请以管理员身份运行(root)