使用数组len来记录前i个元素最长子序列的长度,因此
len[i+1]=max{1,len[k]+1},arr[i+1]>arr[k],for any k<=i;
public static int get(int[] data) {
int[] len = new int[data.length];// 记录最长信息
for (int i = 0; i < len.length; i++) {
len[i] = 1;
}
for (int i = 0; i < data.length; i++) {
for (int j = i - 1; j >= 0; j--) {
if (data[i] > data[j] && len[i] < len[j] + 1) {
len[i] = len[j] + 1;
}
}
}
int max = -1;
for (int i = 0; i < len.length; i++) {
if (max < len[i]) {
max = len[i];
}
}
return max;
}