Leetcode 674 Solution

This article provides solution to leetcode question 674 (longest-continuous-increasing-subsequence)

https://leetcode.com/problems/longest-continuous-increasing-subsequence

Solution

class Solution {
public:
    int findLengthOfLCIS(vector<int>& nums) {
        if (nums.empty())
            return 0;

        int max_len = 0;
        int l = 0;
        int r = 1;

        while (r < nums.size())
        {
            if (nums[r] <= nums[r - 1])
                l = r;

            r++;

            max_len = max(max_len, r - l);
        }

        return max(max_len, r - l);
    }
};