leetcode Longest Increasing Subsequence
2016-05-31 11:47
501 查看
题目链接
动态规划。算法复杂度n平方
动态规划。算法复杂度n平方
public class Solution { public int lengthOfLIS(int[] nums) { if(nums.length==0) { return 0; } int record[]=new int[nums.length]; for(int i=0;i<nums.length;i++) { int max=0; for(int j=0;j<i;j++) { if(nums[j]<nums[i]) { max=Math.max(record[j]+1, max); } } record[i]=max; } int max=0; for(int i=0;i<nums.length;i++) { max=Math.max(max, record[i]); } return max+1; } }
相关文章推荐
- apue第三版学习环境的配置
- iOS开发 UICollectionView属性介绍
- UICollectionView基础
- sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
- iOS开发--GPUImage的使用
- duilib CTextUI 纯字母不能换行
- Arduino 和LCD1602液晶屏 I2C接口实验
- iOS学习应用开发就业课_004:UIButton时间处理
- 关于Linkedlist 和 ArrayDeque的讨论
- iOS监听UITabBar的Tab点击事件
- 347. Top K Frequent Elements
- iOS自定义UITableViewCell registerNib: 与 registerClass: 的区别
- Mirantis OpenStack Fuel8.0离线安装(MOS8.0本地源)
- iOS学习应用开发就业课_003:UIButton基本功能
- iOS开发:UITableView加载多张照片导致内存上涨的问题
- UITextField点击选中文字
- java.sql.SQLException: Connections could not be acquired from the underlying database!
- C#里System.Data.SQLite中对GUID的处理
- 实现placeholder属性的UITextView
- Mirantis OpenStack Fuel6.0安装使用—Step2