Longest Increasing Subsequence(DP)
public static int LIS(List<Integer> al) {
int[] arr = new int[al.size()];
int lis = 0;
arr[0] = 1;
for (int i = 1; i < al.size(); i++) {
if (al.get(i) > al.get(i - 1))
arr[i] = arr[i - 1] + 1;
else
arr[i] = 1;
}
for (int i : arr) {
if (arr[i] > lis)
lis = arr[i];
}
return lis;
}
Longest Increasing Subsequence(DP)的更多相关文章
- HPU第三次积分赛-D:Longest Increasing Subsequence(DP)
Longest Increasing Subsequence 描述 给出一组长度为n的序列,a1,a2,a3,a4...an, 求出这个序列长度为k的严格递增子序列的个数 输入 第一行输入T ...
- POJ 2533——Longest Ordered Subsequence(DP)
链接:http://poj.org/problem?id=2533 题解 #include<iostream> using namespace std; ]; //存放数列 ]; //b[ ...
- 65.Longest Increasing Subsequence(最长增长子序列)
Level: Medium 题目描述: Given an unsorted array of integers, find the length of longest increasing sub ...
- LeetCode OJ:Longest Increasing Subsequence(最长递增序列)
Given an unsorted array of integers, find the length of longest increasing subsequence. For example, ...
- POJ 2533 Longest Ordered Subsequence(DP 最长上升子序列)
Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 38980 Acc ...
- POJ 2533 Longest Ordered Subsequence(dp LIS)
Language: Default Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submis ...
- POJ 2533-Longest Ordered Subsequence(DP)
Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 34454 Acc ...
- HDU 1423 Greatest Common Increasing Subsequence(LCIS)
Greatest Common Increasing Subsequenc Problem Description This is a problem from ZOJ 2432.To make it ...
- Longest common subsequence(LCS)
问题 说明该问题在生物学中的实际意义 Biological applications often need to compare the DNA of two (or more) different ...
随机推荐
- Android ListView 第一次设置Adapter时候getView调用多次
之前遇到这个奇怪现象,记录一下: 使用Listview并设置Adapter时, 会回调多次getView,比如我有4个items,按理说getView应该是调用一次(打出4个log),结果回调有4次( ...
- jquery点击改变class并toggle
<html> <head> <meta charset="utf-8"> <title></title> <scr ...
- 转载:scikit-learn学习之决策树算法
版权声明:<—— 本文为作者呕心沥血打造,若要转载,请注明出处@http://blog.csdn.net/gamer_gyt <—— 目录(?)[+] ================== ...
- SET Transaction Isolation Level Read语法的四种情况
转自:http://www.cnblogs.com/qanholas/archive/2012/01/04/2312152.html 存储过程:SET Transaction Isolation Le ...
- Eclipse换常用的快捷键
还是喜欢ctrl+tab键来切换窗口,ctrl+f6实在不好使. 修改方法:在eclipse中Window -> Perferences -> General -> Keys -&g ...
- Bouncycastle中的RSA技术以及解决之道
一个使用bouncycastle进行安全操作的实用类 2007-04-13 12:54 import java.io.*;import java.security.*;import java.secu ...
- 建立一个node.js服务器(使用express搭建第一个Web环境)
一.官网下载node.js 下载地址:https://nodejs.org/en/download/ 根据向导,下一步安装就可以了! 二.使用express搭建Web环境 express是一个开源的n ...
- wordpress主题结构_源码
WordPress博客主题的工作机制 WordPress主题由一系列模板文件组成,每个文件分别控制主题的特定区域.无论你处于哪个页面都能看到的网站的静态部分,由header文件.sidebar和foo ...
- centos6.5安装mysql记录
1.查看操作系统相关信息. [root@linuxidc ~]# cat /etc/issue CentOS release 6.5 (Final) Kernel \r on an \m [root@ ...
- Linux tar指令
linux 下的命令真是太多了.最近在看<Linux Shell编程从初学到精通>一书.该书有468页,很可惜我并不是那种很有耐性一个例子一个例子地跟着做的人,最多在看到些不太清楚的地方会 ...