Leetcode 674. Longest Continuous Increasing Subsequence

版权声明:博客文章都是作者辛苦整理的,转载请注明出处,谢谢! https://blog.csdn.net/Quincuntial/article/details/83384095

文章作者: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/
阅读更多

扫码向博主提问

SnailTyan

博客专家

非学,无以致疑;非问,无以广识
  • 擅长领域:
  • 深度学习
  • PyTorch
  • OCR
  • Docker
  • Caffe
去开通我的Chat快问
换一批

没有更多推荐了,返回首页