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

示例 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. mysql-connector-java-8.0.12使用时报错

    配置url加 &useSSL=false&serverTimezone=UTC 就可以了

  2. 打开springboot的run dashboard

    默认情况下,idea的run dashboard是关闭的,当检测到你有多个springboot项目时会弹出提示框,询问是否打开. 如果我们想要自己打开,需要修改配置. 在你的idea的项目目录中,有一 ...

  3. Linux自动化工具之crontab (windows需要手动配置相关服务,具体百度)

    //有的shell解释器是/bin/tcsh而不是传统的/bin/bash.而且两者语法有些差异,注意避免.比如设置变量tcsh是set 变量 =`****`   1.crontab是什么,是linu ...

  4. 模板:数位DP

    第一次听说dp还有模板的... 当然你要是记忆化搜索的话,就可以有一些套路 这是一个伪代码: LL Dfs(LL now,限制,LL top){ if(!now) return 判断条件; if(!t ...

  5. ArcMap应用——三维场景中井盖的属性配置

    在精细三维场景中,有地面(包括道路面.马路牙子).有部件数据(包括井盖).我们会发现有马路牙子的地方比道路面要高出一部分,比如0.1米,但是雨水井盖却有些在路面上.有些在道路以外.就是说在道路面上的井 ...

  6. Location protocol 属性

    Location protocol 属性 定义和用法 protocol 属性是一个可读可写的字符串,可设置或返回当前 URL 的协议. 语法 location.protocol <!DOCTYP ...

  7. CentOS 6.5 Apache+SVN使用户可以自己修改密码

    yum -y install php #安装php mkdir /var/www/svnadmin #建立页面目录 vi /var/www/svnadmin/index.php #创建index.ph ...

  8. 爬虫(三)通过Selenium + Headless Chrome爬取动态网页

    一.Selenium Selenium是一个用于Web应用程序测试的工具,它可以在各种浏览器中运行,包括Chrome,Safari,Firefox 等主流界面式浏览器. 我们可以直接用pip inst ...

  9. [Array]122. Best Time to Buy and Sell Stock II(obscure)

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  10. springmvc 传参Required String parameter 'xxxx' is not present

    报错 请求因该是已经被分配了,但是参数补全,无法被执行 加上这个参数就好了,表示请求参数,可以为空 这样的好处是,可以进入controller之后再去判断,比较好定位错误