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

最新文章

  1. 【JSP手记】--jsp里面session.getAttribute(&quot;&#215;&#215;&#215;&quot;)在java中的表示
  2. hdu4920 Matrix multiplication 模3矩阵乘法
  3. RST_n的问题
  4. 获得View的真实高度
  5. node-gyp rebuild 卡住?
  6. C++ STL初学笔记
  7. pci 记录
  8. 使用Xcode查找项目中的中文字符串
  9. (step4.3.1) hdu 1010(Tempter of the Bone——DFS)
  10. 如何在pl/sql developer 7运行到oracle存储过程设置断点的地方
  11. 清华集训2014 day2 task1 简单回路
  12. Jedis-returnResource使用注意事项
  13. 自定义Retrofit转化器Converter
  14. activiti源码编译
  15. YTKNetwork网络封装
  16. Java面试总结(集合、spring)
  17. 【使用指南】WijmoJS 前端开发工具包
  18. kickstart自动安装部署RHEL7
  19. consul在windows下的安装
  20. MVC与MVVM设计模式理解

热门文章

  1. Java、javax、org、sun、Java.util等常用包的区别、详解、实例
  2. sed命令基础
  3. 磁盘管理之inode与block
  4. Spring Boot Maven Plugin(二):run目标
  5. mybatis-java-依赖注入
  6. 谈谈浏览器http缓存
  7. Linux SSH 安装Tomcat
  8. 远程无法访问linux Mysql解决方案
  9. Apache Spark 2.2.0 中文文档 - Submitting Applications | ApacheCN
  10. swift 开发学习问题