Leetcode 674. Longest Continuous Increasing Subsequence

96
SnailTyan
2018.10.25 18:20 字数 31

文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书

1. Description

Longest Continuous Increasing Subsequence

2. Solution

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

Reference

  1. https://leetcode.com/problems/longest-continuous-increasing-subsequence/description/
Leetcode
Web note ad 1