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 ...
随机推荐
- java.sql.SQLException: Io 异常: Connection reset
当数据库连接池中的连接被创建而长时间不使用的情况下,该连接会自动回收并失效,但客户端并不知道,在进行数据库操作时仍然使用的是无效的数据库连接,这样,就导致客户端程序报“ java.sql.SQLExc ...
- mysql 远程访问授权
给mysql改了密码了,程序就不让登录了: mysql 网外链接 Access denied for user 这不能忍啊!咋办?授权呗! 命令行: GRANT ALL PRIVILEGES ON * ...
- 国内的阿里云maven私服
<mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexu ...
- 使用RMAN从磁带库恢复归档文件
最近用RMAN对部分归档日志进行了恢复,在此记录恢复过程 由于不能透漏数据库信息,故举例如下: ORACLE_SID=hrdb 恢复目标路径:/NewRmanbak/restore_archive ...
- HackerRank "Training the army" - Max Flow
First problem to learn Max Flow. Ford-Fulkerson is a group of algorithms - Dinic is one of it.It is ...
- jquery form表单序列号
1.serialize()方法 格式:var data = $("form").serialize(); 功能:将表单内容序列化成一个字符串. 这样在ajax提交表单数据时,就不用 ...
- 127 Word Ladder
Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest t ...
- [备忘]Visio中连接线交叉时跨线小弯的去掉方法
连接线格式->行为->连接线->跨线->添加->从不 format->behavior…->Connector->Line jumps->Add: ...
- 错误记录 git pull
在安装open-falcon的nodata组件,更新库的时候,git pull 报错: You are not currently on a branch, so I cannot use any'b ...
- 冲突--ListView与ScrollView冲突的4种解决方案
众所周知ListView与ScrollView都具有滚动能力,对于这样的View控件,当ScrollView与ListView相互嵌套会成为一种问题: 问题一:ScrollView与ListView嵌 ...