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

示例 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. [转]深入WPF--Style

    Style 用来在类型的不同实例之间共享属性.资源和事件处理程序,您可以将 Style 看作是将一组属性值应用到多个元素的捷径. 这是MSDN上对Style的描述,翻译的还算中规中矩.Style(样式 ...

  2. urllib与urllib2的学习总结

    先啰嗦一句,我使用的版本是python2.7,没有使用3.X的原因是我觉得2.7的扩展比较多,且较之前的版本变化不大,使用顺手.3.X简直就是革命性的变化,用的蹩手.3.x的版本urllib与urll ...

  3. java虚拟机(十一)--GC日志分析

    GC相关:java虚拟机(六)--垃圾收集器和内存分配策略 java虚拟机(五)--垃圾回收机制GC 打印日志相关参数: -XX:+PrintGCDetails -XX:PrintGCTimestam ...

  4. linux平台进行c语言源码安装

    安装c源程序的步骤: 1. ./configure --prefix 执行编译检测 指定安装路径 2. make 编译 3. sudo make install 编译后安装 前两步可以合成一步(mak ...

  5. HDU - 3007 Buried memory

    传送门 最小圆覆盖模板. //Achen #include<algorithm> #include<iostream> #include<cstring> #inc ...

  6. js 设置缓存

    长期存储    localStorage.getItem("key");       //获取键的值    localStorage.setItem("key" ...

  7. hibernate 多表关联外键问题无法截断表的解决办法

    目前只有一个办法 就是手动清除其他表的外键关联,然后在做一个小swing单独去操作这个表,而不运行主控方相关的代码 当web运行后,外键会再次设置好

  8. CSP-S 2019 Day 2 T3 树的重心

    CSP-S 2019 Day 2 T3 树的重心 题 给出了一个大小为\(n\)的树,树中结点从 1∼n 编号.小简单的课后作业是求出这棵树单独删去每条边后,分裂出的两个子树的重心编号和之和. \(n ...

  9. Leetcode113. Path Sum II路径总和2

    给定一个二叉树和一个目标和,找到所有从根节点到叶子节点路径总和等于给定目标和的路径. 说明: 叶子节点是指没有子节点的节点. 示例: 给定如下二叉树,以及目标和 sum = 22, 5 / \ 4 8 ...

  10. CENTOS 7更换系统启动默认内核

    本文不再更新,可能存在内容过时的情况,实时更新请移步原文地址:CENTOS 7更换系统启动默认内核: 环境: CentOS Linux release 7.6.1810 (Core) : 1.查看当前 ...