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

示例 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. WildFly配置gzip压缩

    使用jboss-cli.sh 执行下面的脚本 /subsystem=undertow/configuration=filter/gzip=gzipFilter:add() /subsystem=und ...

  2. 嘴巴题6 BZOJ3450JoyOI1952 Easy

    Time Limit: 10 Sec Memory Limit: 128 MB Submit: 936 Solved: 698 [Submit][Status][Discuss] Descriptio ...

  3. DataSourceUtils(加入线程管理事务)

    第一二见之前的文章: DataSourceUtils(使用C3P0连接池的工具类) 替换第三步: import java.sql.Connection; import java.sql.ResultS ...

  4. ArcGIS 10.2 for Server 集群部署

    ArcGIS 10.2 for Server 具有很灵活的体系结构,而 ArcGIS 10.2  forServer site 可以包含一台或多台安装 GIS Server 的机器,这些参与ArcGI ...

  5. 线段树区间更新+区间求和模板(数组实现)洛谷p3372,p3373

    模板题目1:https://www.luogu.org/problemnew/show/P3372 懒惰标记讲解:https://www.cnblogs.com/wushengyang/p/11194 ...

  6. 推荐大家一个个人觉得超级好的Java学习网站

    https://how2j.cn?p=16567 这是网址,网站里有Java基础,Javaweb.框架.数据库.工具.面试题等等的,站长一直在更新新的知识,很好用哦

  7. 用canvas 画出圆形图片

    /** * 把图片处理成圆形,如果不是正方形就按最小边一半为半径处理 * @param {object} imgObj 图片(img)对象 * @param {number} imgType 设置生成 ...

  8. input输入框的input事件和change事件

    input输入框的onchange事件,要在 input 失去焦点的时候才会触发: 在输入框内容变化的时候不会触发change,当鼠标在其他地方点一下才会触发: onchange 事件也可用于单选框与 ...

  9. 严格模式下顶层箭头函数this指向的是全局对象

    我们知道普通函数调用,this在非严格模式下指向全局对象,在严格模式下是undefined.那箭头函数呢?我们知道,箭头函数没有自己的this,它的this是最近外层非箭头函数的this,那直接在顶层 ...

  10. socker TCP UDP BIO NIO

    BIO:  Java 1.4 以前只有之中方式. bio:阻塞式IO, 一个 socker 连接占用一个 线程.如果 IO 阻塞,会在传输速度限制,这个线程也会一直等待在这里,等待从socker 的 ...