---
title: "Longest Increasing Subsequence"
author: "kaqi"
date: "2016-05-17T11:22:52Z"
tags: []
categories: ["编程语言"]
slug: "longest-increasing-subsequence"
draft: false
lastmod: "2016-05-17T11:22:52Z"
id: 2298700
url: "https://kaqi.iteye.com/blog/2298700"
---

```
public class Solution {
           public int lengthOfLIS(int[] nums) {

        if(nums.length==0){
            return 0;
        }
        int[] lens= new int[nums.length];
        lens[0]=1;
        int max=1;
        for(int i=1;i<nums.length;i++){
            for (int j = 0; j < i; j++) {
                if(nums[i]>nums[j] && lens[i]<lens[j]){
                    lens[i]=lens[j];
                }
            }
            lens[i]++;
            max=Math.max(max,lens[i]);
        }
        return max;
    }
}
```