分析:指定两个指针,point1为哨兵,point2来动态查询最长序列
代码
public class Main {
public static void main(String[] args) {
int[] a = {1,6,8,3,2,0,61};
int max = 1;
int point1 = 0;
while (point1 < a.length - 1) {
int longer = 1;
for (int i = point1; i < a.length-1; i++) {
int point2 = i + 1;
if (a[point2] > a[i]) {
longer++;
max =max < longer?longer:max;
} else
point1 = point2 + 1;
}
}
System.out.println(max);
}
}