Leetcode 674 Longest Continuous Increasing Subsequence

来源:互联网 发布:window10 共享端口 编辑:程序博客网 时间:2024/06/06 00:51

Leetcode 674 Longest Continuous Increasing Subsequence

#include <vector>using namespace std;class Solution {public:    int findLengthOfLCIS(vector<int>& nums) {    int maxLength = 1;    int count = 1;    int size = nums.size();    if(nums.empty())      return 0;    for(int i = 1;i < size;i ++)    {        if(nums[i] > nums[i - 1])        {        count ++;        }        else        {        if(count > maxLength)        {            maxLength = count;            }        count = 1;        }    }    return maxLength > count ? maxLength : count;    }};
阅读全文
0 0
原创粉丝点击