# Longest Continuous Increasing Subsequence

• class Solution {
public int findLengthOfLCIS(int[] nums) {
int skip = 0,length = 1;
for (int i = 0;i<nums.length -1;i++){
if (nums[i+1]-nums[i] != 0){
if(nums[i+1]-nums[i] == skip){
length++;
}else{
skip = nums[i+1]-nums[i];
}

``````        }else{
skip = nums[i+1]-nums[i];
length = 1;
}
}
return length;
}
``````

}

• ``````class Solution {
public int findLengthOfLCIS(int[] nums) {

if (nums.length==0)return 0;
if (nums.length==1)return 1;

int counter =0;
int max = Integer.MIN_VALUE;
for (int i=1;i<nums.length;i++){

if (nums[i]>nums[i-1])
{
counter++;
if (i==nums.length-1&&counter>=max)return counter+1;
}
else if(counter>max){
max = counter;
counter=0;
}
else counter = 0;
}

return max+1;
}
}``````

• Why is it "if i and nums[i-1] >= nums[i]" what does "if i" do?
Can't it just be "if nums[i-1] >= nums[i]"

• class Solution {
public int findLengthOfLCIS(int[] nums) {
if(nums.length == 0) return 0;
int res = 1;
int max = Integer.MIN_VALUE;
for(int i = 0; i < nums.length - 1; i++){
if(nums[i] < nums[i+1]){
res++;
}else{
if(res > max) max = res;
res = 1;
}
}
return Math.max(res,max);
}
}

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