AC Java Solution


  • 0
    A
    public int findLengthOfLCIS(final int[] nums) {
            if (nums.length == 0) {
                return 0;
            }
    
            int currentLength = 1, maxLength = 1;
    
            for (int i = 1; i < nums.length; i++) {
                if (nums[i] <= nums[i-1]) {
                    maxLength = Math.max(maxLength, currentLength);
                    currentLength = 1;
                } else {
                    currentLength++;
                }
            }
    
            return Math.max(maxLength, currentLength);
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.