Leetcode

Leetcode 674. Longest Continuous

2018-10-25  本文已影响1人  SnailTyan

文章作者: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/
上一篇下一篇

猜你喜欢

热点阅读