没啥好讲的题,直接贴代码:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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