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. List集合和Set集合UML图总结

    1.List和Set,用RationalRose展示 2.Map

  2. vuetify使用时遇到的坑:默认颜色显示不了

    原文链接: https://blog.csdn.net/weixin_44015248/article/details/86579777

  3. Java中String、StringBuilder和StringBuffer

    StringBuilder和StringBuffer内部都是通过char[]来实现的.(jdk1.9后,底层把char 数组变成了byte[].)唯一不同的就是我们的StringBuffer内部操作方 ...

  4. Oracle 控制文件损坏解决方案

    Oracle 控制文件损坏解决方案 故障一:丢失(损坏)一个控制文件 前台报错:ORA-00205:error in identifying control file,check alert log ...

  5. 爬虫(九):scrapy框架回顾

    scrapy文档 一:安装scrapy a. pip3 install wheel b. 下载twisted http://www.lfd.uci.edu/~gohlke/pythonlibs/#tw ...

  6. start-stop-daemon 守护进程管理

    start-stop-daemon 守护进程管理 start-stop-daemon 作为系统自带,简单实用 结合systemctl,用起来很是不错. 示例 PIDFILE=/var/run/ngin ...

  7. 理解 java 使用 异或 交换两数

    网上看了一些使用异或交换两数,不是很好理解.现在写一下自己的理解. 首先是 异或原则,对于任意 x: x ^ x == 0; x ^ 0 == x; 思路: 根据原则,可以得到两个公式: 求a:    ...

  8. PowerShell中汉字与ASCII码相互转换

    function asc($param) { $rtn = '' $list = $param -split '' foreach ($char in $list) { if($char -ne '' ...

  9. 【SPOJ】Distinct Substrings

    [SPOJ]Distinct Substrings 求不同子串数量 统计每个点有效的字符串数量(第一次出现的) \(\sum\limits_{now=1}^{nod}now.longest-paren ...

  10. nginx 转发 header 数据丢失

    刚帮同事解决了个问题,记录一下,现象:放在header里面的数据,本地后台可以收到,集成可以收到,测试不行, 查看代码没问题,排除代码问题,比较集成和测试环境有何不同,发现集成环境是局域网访问,192 ...