最长连续递增序列

给定一个未经排序的整数数组,找到最长且连续递增的子序列,并返回该序列的长度。

序列的下标是连续的

public class MaxSeq {
    public static void main(String[] args) {
        System.out.println(findLength(new int[]{1,2,3,2,3,4,3,4,5,6,7}));
    }
    public static int findLength(int[] nums){
        int start=0;
        int 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;
    }
}
posted @ 2021-07-29 21:38  落笔生花  阅读(46)  评论(0)    收藏  举报