# C#LeetCode刷题之#674-最长连续递增序列（ Longest Continuous Increasing Subsequence）

Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray).

Input: [1,3,5,4,7]

Output: 3

Explanation: The longest continuous increasing subsequence is [1,3,5], its length is 3. Even though [1,3,5,7] is also an increasing subsequence, it’s not a continuous one where 5 and 7 are separated by 4.

Input: [2,2,2,2,2]

Output: 1

Explanation: The longest continuous increasing subsequence is [2], its length is 1.

Note: Length of the array will not exceed 10,000.

```public class Program {

public static void Main(string[] args) {
int[] nums = null;

nums = new int[] { 1, 3, 5, 7 };
var res = FindLengthOfLCIS(nums);
Console.WriteLine(res);

}

private static int FindLengthOfLCIS(int[] nums) {
//没什么好说的，后面比前面大就计数，用max记录最大的连续的的递增序列
if(nums.Length == 0) return 0;
int count = 0, max = 0;
for(int i = 0; i < nums.Length - 1; i++) {
if(nums[i + 1] > nums[i]) {
count++;
} else {
max = Math.Max(max, count);
count = 0;
}
}
max = Math.Max(max, count);
return max + 1;
}

}```

`4`