Longest Continuous Increasing Subsequence LeetCode solution in C++

1
class Solution {
2
public:
3
int findLengthOfLCIS(vector<int> &nums) {
4
int maxLength = 1;
5
int currLength = 1;
6
int i = 0;
7
int j = 1;
8

9
while (j < nums.size()) {
10
if (nums[j] > nums[i]) {
11
currLength++;
12
i++;
13
j++;
14
if (currLength > maxLength) maxLength = currLength;
15
} else {
16
currLength = 1;
17
i = j;
18
j++;
19
}
20
}
21
return maxLength;
22
}
23
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0