动规基础,最长上升子序列
来源:互联网 发布:plc步进电机编程实例 编辑:程序博客网 时间:2024/04/20 16:13
package com.ohere;public class LongestIncreasingSubSet {public static void main(String[] args) {// TODO Auto-generated method stubint[] test = {1,7,3,5,9,4,8,9,10};longestString(test);}public static void longestString(int [] str){int [] maxLength = new int[str.length];maxLength[0] = 1;for (int i = 1; i < str.length; i++){int tempLen = 0;for (int j = 0; j < i;j++){if (str[j] < str[i]){tempLen = Math.max(tempLen, maxLength[j]);}}maxLength[i] = tempLen + 1;}int result = 0;for (int x: maxLength){result = Math.max(result, x);}System.out.println(result);}}
0 0
- 动规基础,最长上升子序列
- 【例题】【动规】最长上升子序列
- 动规之最长上升子序列
- HDU-1025-动规-最长上升子序列
- 8596 最长上升子序列(动规)
- 最长上升子序列之基础
- 【基础算法】最长上升子序列
- uva10534 - Wavio Sequence(动归,最长上升子序列)
- 最长上升子序列
- 最长上升子序列
- 最长上升子序列
- 最长上升子序列
- 最长上升子序列
- 最长上升子序列
- 最长上升子序列
- 最长上升子序列
- 最长上升子序列
- 最长上升子序列
- Activiti环境搭建(非与Spring整合),以及入门实例--001
- 内存泄露
- HDU 1017 简单数学题
- android init.rc 到底在哪里?
- 堆和栈的区别
- 动规基础,最长上升子序列
- MyEclipse快速开发Hibernate过程图解教程
- ssh面试精华
- GDI 画图问题集锦
- 面试技能五
- Mob推出全球免费短信验证码解决方案
- C++中指针和引用的区别
- 网络负载均衡环境下wsHttpBinding+Message Security+Windows Authentication的常见异常
- java程序设计第一课