无序数组的最长递增子序列

来源:互联网 发布:工商数据查询 编辑:程序博客网 时间:2024/05/17 21:55
package offer;


public class Main {


public static void main(String[] args) {
// TODO Auto-generated method stub

}


public int findLongest(int[] A, int n) {
       // write code here
int max = 0;
int dp[] = new int [n];
dp[0] = 1;
for(int i = 0;i<A.length;i++) {

for(int j = 0;j<i;j++) {
if(A[j]<A[i]&&dp[j]+1>dp[i]) {
dp[i] = dp[j]+1;
max = max>dp[i]?max:dp[i];
}
}
}
return max;
   }
}