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

Example 1:

Input: [1,3,5,4,7]
Output: 3
Explanation: The longest continuous increasing subsequence is [1,3,5], its length is 3.
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:

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

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


题目标签:Array

  题目给了一个没有排序的nums array,让我们找到其中最长连续递增序列的长度。

  维护一个maxLen,每次遇到递增数字就tempLen++,遇到一个不是递增数字的话,就把tempLen 和maxLen 中大的保存到maxLen。

Java Solution:

Runtime beats 69.72%

完成日期:10/21/2017

关键词:Array

关键点:维护一个maxLen

 class Solution
{
public int findLengthOfLCIS(int[] nums)
{
if(nums == null || nums.length == 0)
return 0; int maxLen = 0;
int tempLen = 1; for(int i=1; i<nums.length; i++)
{
if(nums[i] <= nums[i-1])
{
maxLen = Math.max(maxLen, tempLen);
tempLen = 1;
}
else
{
tempLen++;
} } return Math.max(maxLen, tempLen);
}
}

参考资料:N/A

LeetCode 题目列表 - LeetCode Questions List

LeetCode 674. Longest Continuous Increasing Subsequence (最长连续递增序列)的更多相关文章

  1. [LeetCode] 674. 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] 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. Leetcode674.Longest Continuous Increasing Subsequence最长连续递增序列

    给定一个未经排序的整数数组,找到最长且连续的的递增序列. 示例 1: 输入: [1,3,5,4,7] 输出: 3 解释: 最长连续递增序列是 [1,3,5], 长度为3. 尽管 [1,3,5,7] 也 ...

  6. [Leetcode]674. Longest Continuous Increasing Subsequence

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

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

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

  8. 【Leetcode_easy】674. Longest Continuous Increasing Subsequence

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

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

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

随机推荐

  1. iOS内购 服务端票据验证及漏单引发的思考.

    因业务需要实现了APP内购处理,但在过程中出现了部分不可控的因素,导致部分用户反映有充值不成并漏单的情况. 仔细考虑了几个付费安全上的问题,凡是涉及到付费的问题都很敏感,任何一方出现损失都是不能接受的 ...

  2. JSP知识点大纲图

    这是我整理出来的JSP知识点大纲图,具体的内容都可以在我的博文中找到-.

  3. 源码安装H2O Http 服务端程序到Ubuntu服务器

    首先安装全家桶 apt install -y build-essential zlib1g-dev libpcre3 libpcre3-dev unzip cmake libncurses5-dev ...

  4. (转)添加PROPAGATION_REQUIRES_NEW 事务没有产生作用

    最近在做事务添加时  发现自己的事务没有新建,上网查到   仅用作收藏. 其二  注意  事务的注解  应该在 内层的事务上面 一.描述 Spring遇到嵌套事务时,当被嵌套的事务被定义为" ...

  5. websocket的理解及实例应用

    websocket协议是HTML5提出的一个新的规范,主要用于实现服务器及时推送信息给客户端的功能. websocket实现是基于HTTP协议的部分握手功能,但是websocket仅仅握手一次即可进行 ...

  6. Delphi中paramstr的用法

    原型                function   paramstr(i:index):string        对于任何application paramstr(0)都默认代表的是应用程序的 ...

  7. OpenVPN client端配置文件详细说明(转)

    本文将介绍如何配置OpenVPN客户端的配置文件.在Windows系统中,该配置文件一般叫做client.ovpn:在Linux/BSD系统中,该配置文件一般叫做client.conf.虽然配置文件名 ...

  8. Jquery插件之ajaxForm ajaxSubmit的理解用法(转)

    我们在平常使用Jquery异步提交表单,一般是在submit()中,使用$.ajax进行.比如: $(function(){ $('#myForm').submit(function(){ $.aja ...

  9. 一个强迫症的Git 选择

    选择 1,经常性的commit or 干净的历史 在本地(私有)的开发分支中,选择经常性的commit,以便于实时记录修改,回退等操作.eg.develop,feature... 实现方式: comm ...

  10. 华为olt ma5680t常用命令详解

    进入待替换的故障ONU所注册的单板 interface epon 0/1         //此处可以通过查看PON口下设备状态来获取需要替换的ONU ID.假设故障设备位于2端口,ID为6 ont ...