problem

674. Longest Continuous Increasing Subsequence

solution

class Solution {
public:
int findLengthOfLCIS(vector<int>& nums) {
int res = , cnt = , cur = INT_MAX;
for(auto num:nums)
{
if(num>cur) cnt++;
else cnt = ;
res = max(res, cnt);
cur = num;
}
return res;
}
};

solution2:

class Solution {
public:
int findLengthOfLCIS(vector<int>& nums) {
int res = , cnt = ;
for(int i=; i<nums.size(); ++i)
{
if(i== || nums[i]>nums[i-]) res = max(res, ++cnt);
else cnt = ;
}
return res;
}
};

参考

1. Leetcode_easy_674. Longest Continuous Increasing Subsequence;

2. Grandyang;

【Leetcode_easy】674. Longest Continuous Increasing Subsequence的更多相关文章

  1. 【LeetCode】674. Longest Continuous Increasing Subsequence 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 动态规划 空间压缩DP 日期 题目地址:https: ...

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

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

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

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

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

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

  5. [Leetcode]674. Longest Continuous Increasing Subsequence

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

  6. [LeetCode&Python] Problem 674. Longest Continuous Increasing Subsequence

    Given an unsorted array of integers, find the length of longest continuousincreasing subsequence (su ...

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

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

  8. 674. Longest Continuous Increasing Subsequence@python

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

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

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

随机推荐

  1. [Angular] Using Pipe for function memoization

    Sometimes we might have some expensive function to calcuate state directly from template: <div cl ...

  2. sqlserver内存、会话、连接查询

    1.连接查询 select * from sysprocesses where dbid in (select dbid from sysdatabases where name='dbname') ...

  3. 使用jQuery快速高效制作网页交互特效---JavaScript对象及初始面向对象

    一.JavaScript中的基本数据类型 number(数值类型)    string(字符串类型)    boolean(布尔类型)    null(空类型)    undefined(未定义类型) ...

  4. Ftp客户端需要TSL功能的文件上传

    Ftp客户端需要TSL功能 1.由于最近做了一个项目,需要把打包的文件传输到对方的FTP服务器上,但是用普通的java连接ftp客户端总是连接不上去,对方却说ftp客户端需要开通TSL功能. 直接上代 ...

  5. greenplum(postgresql) 数据字典

    greenplum是基于postgresql开发的分布式数据库,里面大部分的数据字典是一样的.我们在维护gp的时候对gp的数据字典比较熟悉,特此分享给大家.在这里不会详细介绍每个字典的内容,只会介绍常 ...

  6. WCF wsHttpBinding in SoapUI

    当使用wsHttpBinding,而不是平时用的webHttpBinding的时候,用soapui会报错.这个时候需要选中WS-A选项中的"Add default wsa:Action&qu ...

  7. surprise库官方文档分析(三):搭建自己的预测算法

    1.基础 创建自己的预测算法非常简单:算法只不过是一个派生自AlgoBase具有estimate 方法的类.这是该方法调用的predict()方法.它接受内部用户ID,内部项ID,并返回估计评级r f ...

  8. linux系列(三):pwd命令

    1.命令格式: pwd [选项] 2.命令功能 查看”当前工作目录“的完整路径 3.常用参数 -L:显示当前路径,有连接文件时,直接显示连接文件的路径(不加参数时默认此方式) -P:显示当前的路径,有 ...

  9. 10月清北学堂培训 Day 7

    今天是黄致焕老师的讲授~ 历年真题选讲 NOIP 2012 开车旅行 小 A 和小 B 决定外出旅行,他们将想去的城市从 1 到 n 编号,且编号较小的城市在编号较大的城市的西边.记城市 i 的海拔高 ...

  10. Vue自定义日历组件

    今天给大家介绍Vue的日历组件,可自定义样式.日历类型及支持扩展,可自定义事件回调.Props数据传输. 线上demo效果 示例 Template: <Calendar :sundayStart ...