Thursday, September 14, 2017

[LeetCode]Longest Continuous Increasing Subsequence


没啥好讲的题,直接贴代码:


class Solution {
public:
int findLengthOfLCIS(vector<int>& nums) {
int len = nums.size(), maxLen = 1, currLen = 1;
if(!len)return 0;
for(int i = 1; i < len; ++i)
{
if(nums[i] > nums[i - 1])
++currLen;
else
currLen = 1;
maxLen = max(currLen, maxLen);
}
return maxLen;
}
};

No comments:

Post a Comment