题解:
class Solution {
public:
int findLengthOfLCIS(vector<int>& nums) {
if(nums.size() <= 0) {
return 0;
}
int prev_num = nums[0];
int max_len = 1;
int tmp_len = 1;
for(int i = 1; i < nums.size(); ++i) {
if(nums[i] > prev_num) {
++tmp_len;
} else {
max_len = max(max_len, tmp_len);
tmp_len = 1;
}
prev_num = nums[i];
}
// 最后一组递增的情况,1,3,5,7
max_len = max(max_len, tmp_len);
return max_len;
}
};