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

Example 1:

  1. Input: [1,3,5,4,7]
  2. Output: 3
  3. Explanation: The longest continuous increasing subsequence is [1,3,5], its length is 3.
  4. Even though [1,3,5,7] is also an increasing subsequence, it's not a continuous one where 5 and 7 are separated by 4.

Example 2:

  1. Input: [2,2,2,2,2]
  2. Output: 1
  3. Explanation: The longest continuous increasing subsequence is [2], its length is 1.

Note: Length of the array will not exceed 10,000.

  1. class Solution {
  2. public int findLengthOfLCIS(int[] nums) {
  3. if (nums == null || nums.length == 0) {
  4. return 0;
  5. }
  6. int cur = 1, res = 1;
  7. for (int i = 1; i < nums.length; i++) {
  8. if (nums[i] > nums[i - 1]) {
  9. cur += 1;
  10. res = Math.max(res, cur);
  11. } else {
  12. cur = 1;
  13. }
  14. }
  15. return res;
  16. }
  17. }

[LC] 674. Longest Continuous Increasing Subsequence的更多相关文章

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

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

  2. 【Leetcode_easy】674. Longest Continuous Increasing Subsequence

    problem 674. Longest Continuous Increasing Subsequence solution class Solution { public: int findLen ...

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

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

  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]674. Longest Continuous Increasing Subsequence

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

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

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

  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. linux常用命令及小知识点

    网络跟踪: 1.mtr  2.tractroute  3.ping 下载命令 curl -O  /path/xx wget 直接下载,将文件下载至当前目录 2.linux非22端口进行双机互信时候pu ...

  2. 基于Token的身份验证

    最近了解下基于 Token 的身份验证,跟大伙分享下.很多大型网站也都在用,比如 Facebook,Twitter,Google+,Github 等等,比起传统的身份验证方法,Token 扩展性更强, ...

  3. 《Docekr入门学习篇》——Docker网络及数据卷

    Docker网络设置 默认情况下docker会创建一个桥接网卡[docker 0],docker有两种映射方式,一种是随机映射,一种是指定映射. 提示:生产场景一般不使用随机映射,但是随机映射的好处是 ...

  4. LeetCode——48. 旋转图像

    给定一个 n × n 的二维矩阵表示一个图像. 将图像顺时针旋转 90 度. 说明: 你必须在原地旋转图像,这意味着你需要直接修改输入的二维矩阵.请不要使用另一个矩阵来旋转图像. 示例 1: 给定 m ...

  5. GitHub 中 readme 如何添加图片

    一.Readme 是什么 readme文件一般是放在github 每个repo的根目录下,用来解释.说明本repo的主要内容和相关信息.而且在repo主页进去的时候会被自动加载.一般采用md标记的文本 ...

  6. maven中scope属性有哪些

    compile,缺省值,适用于所有阶段,会随着项目一起发布. provided,类似compile,期望JDK.容器或使用者会提供这个依赖.如servlet.jar. runtime,只在运行时使用, ...

  7. CaptchaCodeManager

    package org.linlinjava.litemall.wx.service; import org.linlinjava.litemall.wx.dto.CaptchaItem; impor ...

  8. 吴裕雄--天生自然 PYTHON3开发学习:数据库连接 - PyMySQL 驱动

    import pymysql # 打开数据库连接 db = pymysql.connect("localhost","testuser","test1 ...

  9. Django框架的前奏(安装及介绍)

    几个重要的概念: web的本质: 浏览器中输入网址敲回车发生了几件事? 1.浏览器向服务端发送请求 2.服务端接收请求 3.服务端返回相应的响应 4.浏览器接收响应  根据特定的规则渲染页面展示给用户 ...

  10. jQuery方法及使用

    jQuery内容: 选择器 筛选器 样式操作 文本操作 属性操作 文档处理 事件 动画效果 插件 each.data.Ajax 剩余未写的有: 1.表单筛选器: :text :password :fi ...