[leetcode]674. Longest Continuous Increasing Subsequence

[leetcode]674. Longest Continuous Increasing Subsequence


Analysis

嘻嘻~—— [嘻嘻~]

Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray).
简单题~

Implement

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

猜你喜欢

转载自blog.csdn.net/weixin_32135877/article/details/81087749