给定一个未经排序的整数数组,找到最长且连续的的递增序列。

示例 1:

输入: [1,3,5,4,7] 输出: 3 解释: 最长连续递增序列是 [1,3,5], 长度为3。 尽管 [1,3,5,7] 也是升序的子序列, 但它不是连续的,因为5和7在原数组里被4隔开。

示例 2:

输入: [2,2,2,2,2] 输出: 1 解释: 最长连续递增序列是 [2], 长度为1。

注意:数组长度不会超过10000。

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

Leetcode674.Longest Continuous Increasing Subsequence最长连续递增序列的更多相关文章

  1. [LeetCode] Longest Continuous Increasing Subsequence 最长连续递增序列

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...

  2. LeetCode 674. Longest Continuous Increasing Subsequence最长连续递增序列 (C++/Java)

    题目: Given an unsorted array of integers, find the length of longest continuous increasing subsequenc ...

  3. [LeetCode] 674. Longest Continuous Increasing Subsequence 最长连续递增序列

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...

  4. 674. Longest Continuous Increasing Subsequence最长连续递增子数组

    [抄题]: Given an unsorted array of integers, find the length of longest continuous increasing subseque ...

  5. [Swift]LeetCode674. 最长连续递增序列 | Longest Continuous Increasing Subsequence

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence (s ...

  6. LeetCode 674. Longest Continuous Increasing Subsequence (最长连续递增序列)

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...

  7. LeetCode 674. 最长连续递增序列(Longest Continuous Increasing Subsequence) 18

    674. 最长连续递增序列 674. Longest Continuous Increasing Subsequence 题目描述 给定一个未经排序的整型数组,找到最长且连续的递增序列. Given ...

  8. C#LeetCode刷题之#674-最长连续递增序列( Longest Continuous Increasing Subsequence)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3734 访问. 给定一个未经排序的整数数组,找到最长且连续的的递增 ...

  9. leetcode300. Longest Increasing Subsequence 最长递增子序列 、674. Longest Continuous Increasing Subsequence

    Longest Increasing Subsequence 最长递增子序列 子序列不是数组中连续的数. dp表达的意思是以i结尾的最长子序列,而不是前i个数字的最长子序列. 初始化是dp所有的都为1 ...

随机推荐

  1. 论文翻译—SPP-Net(目标检测)

    SPPNet论文翻译 <Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition> Kai ...

  2. [转]Expression Blend实例中文教程(8) - 动画设计快速入门StoryBoard

    上一篇,介绍了Silverlight动画设计基础知识,Silverlight动画是基于时间线的,对于动画的实现,其实也就是对对象属性的修改过程. 而Silverlight动画分类两种类型,From/T ...

  3. 分批次删除大表数据的shell脚本

    #!/bin/bash # 分别是主机名,端口,用户,密码,数据库,表名称,字段名称 readonly HOST="XXX" readonly PORT=" readon ...

  4. charles for https

    To remotely capture http or https traffic with charles you will need to do the following: HOST - Mac ...

  5. Spring AOP(二)--注解方式

    本文介绍通过注解@AspectJ实现Spring AOP,这里要重点说明一下这种方式实现时所需的包,因为Aspect是第三方提供的,不包含在spring中,所以不能只导入spring-aop的包,为了 ...

  6. 修改maven本地库路径

    1.打开maven的安装路径:${M2_HOME}/conf/setings.xml文件 2.找到<localRepository>项,将它的值修改就可以了,我修改的是:${M2_HOME ...

  7. Jmeter分布式测试过程中遇到的问题及摘抄前辈问题汇总

    遇到的常见问题: 1.在Controller端上控制某台机器Run,提示"Bad call to remote host". 解决方法:检查被控制机器上的jmeter-server ...

  8. leetcode 843. Guess the Word

    我做过的第一个 interactive problem 给一个候选词列表,每次猜测可以猜里面的词,会返回猜中匹配的个数, 可以猜10次, 加上随机化策略之后几乎可以一定通过测试(尽管不是100%) c ...

  9. GVEdit中使用graphviz

    官方文档 安装完graphviz后,文档在安装目录下,位置如下 E:\Gra2.38\share\graphviz\doc\html 中文乱码解决 将文件保存为utf-8编码 fontname=&qu ...

  10. fft模板 HDU 1402

    // fft模板 HDU 1402 #include <iostream> #include <cstdio> #include <cstdlib> #includ ...