最长连续递增序列
- 数组中最长的、连续的、递增的(子)序列,下统称子序列
- 设置start变量表示递增子序列在数组中开始的下标
- 设置max表示最长的子序列长度
代码:
//The longest continuously increasing sequence 最长连续递增序列
public class LCISequence {
public static void main(String[] args) {
int[] nums = {1,3, 3,4,5,6, 1,99,100, 23,24,25,26,27};
System.out.println(findLength(nums));
}
public static int findLength(int[] nums){
int start=0,max=0;
for (int i = 1;i<nums.length;i++){
if (nums[i]<=nums[i-1]){
start = i;
}
max = Math.max(max,i-start+1);
}
return max;
}
}