Java Code


  • 0
    V
    class Solution {
        public int findLengthOfLCIS(int[] nums) {
            if(nums == null || nums.length == 0) return 0;
            
            int start = 0;
            int max = 0;
            int len = nums.length;
            
            for(int i=1;i<len;++i){
                if(nums[i] <= nums[i-1]){
                    max = max < i-start ? i-start : max;
                    start = i;
                }
            }
            
            max = max < len-start ? len-start : max;        
            return max;
        }
    }
    

Log in to reply
 

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