最长递增子序列

题目

分析

最长递增子序列

代码

public class AscentSequence {
    public int findLongest(int[] A, int n) {
        // write code here
        int[] tempArray=new int[A.length];
        int result=0;
        for(int i=0;i<A.length;i++){
            int max=1;
            for(int j=i-1;j>=0;j--){
                if(A[i]>A[j]){
                    max=tempArray[j]+1>max?tempArray[j]+1:max;
                }
            }
            tempArray[i]=max;
            result=result>max?result:max;
        }
        return result;
    }
}
posted @ 2018-04-10 09:22  baixiaoshuai  阅读(89)  评论(0编辑  收藏  举报