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 ...
随机推荐
- matlab语言基础
(一)常用命令 清空命令窗口:clc 清空工作空间:clear 打开editor:edit 查看函数的帮助信息:help 函数名 让命令窗口信息紧凑显示:format compact (二)变量与常 ...
- fastjson 使用方法
Fastjson介绍 Fastjson是一个Java语言编写的JSON处理器. 1.遵循http://json.org标准,为其官方网站收录的参考实现之一. 2.功能qiang打,支持JDK的各种类型 ...
- MS CRM 2011的自定义和开发(11)——插件(plugin)开发(二)
http://www.cnblogs.com/StoneGarden/archive/2012/02/06/2339490.html MS CRM 2011的自定义和开发(11)——插件(plugin ...
- 【linux】压缩和解压缩
.gz格式 压缩gzip: gzip只能压缩文件,且压缩后文件消失,不能压缩目录. [root@andon tmp]# ls ml orbit-gdm pulse-2sLvu7UbjUYf pulse ...
- php 添加redis扩展(二)
php代码操作redis 1.连接 <?php //连接本地的 Redis 服务 $redis = new Redis(); $redis->connect('127.0.0.1', 63 ...
- vue通过判断写样式(v-bind)
v-bind:style="$index % 2 > 0?'background-color:#FFF;':'background-color:#D4EAFA;'"
- (转)textarea去掉右侧滚动条,去掉右下角拖拽
本文转载自:http://blog.csdn.net/cctv_end/article/details/7946188 代码: <TEXTAREA style= "overflo ...
- 204. Count Primes
Description: Count the number of prime numbers less than a non-negative number, n. ============= 找质数 ...
- window下部署php_redis扩展
关于redis的一些特性就不多说了,可以到这里去了解,or click me. 另外,给出一个redis中文API,点我. 首先要下载一个redis软件,可以到官网下载. 注意:官网提供的版本比较高级 ...
- 一.OSI与TCP
一. TCP/IP的由来 OSI参考模型由来 计算机网络产生的最初阶段,每个计算机厂商都实现了自己的一套计算机网络体系结构;异构的网络之间无法进行通信.因此,ISO委员会推出了一种用于开放系统互联的网 ...