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

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.

class Solution(object):
def findLengthOfLCIS(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return 0
ans=1
count=1
n=len(nums)
i=1
while i<n:
if nums[i-1]<nums[i]:
count+=1
else:
if ans<count:
ans=count
count=1
i+=1
if ans<count:
return count
return ans

  

[LeetCode&Python] Problem 674. Longest Continuous Increasing Subsequence的更多相关文章

  1. 【Leetcode_easy】674. Longest Continuous Increasing Subsequence

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

  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 解题报告(Python)

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

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

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

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

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

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

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

随机推荐

  1. HDFS数据节点DataNode未启动解决方法

    在解决这个问题的过程中,我又是积累了不少经验... 首先让我搞了很久的问题是,书上说进程全部启动的命令是/bin/start-all.sh,但是当我执行的时候显示command not found.后 ...

  2. leecode第一百四十八题(排序链表)

    class Solution { public: void sort_list(ListNode* head1, ListNode* head2,int len)//在原链表上进行排序 { ListN ...

  3. pytest文档14-函数传参和firture传参数request

    前言 为了提高代码的复用性,我们在写用例的时候,会用到函数,然后不同的用例去调用这个函数. 比如登录操作,大部分的用例都会先登录,那就需要把登录单独抽出来写个函数,其它用例全部的调用这个登陆函数就行. ...

  4. 重写console.log的一些理解

    关于重写console.log的方式通常都是这样的: console.log = (function(oriLogFunc){ return function(str) { oriLogFunc.ca ...

  5. python 爬虫&爬取豆瓣电影top250

    爬取豆瓣电影top250from urllib.request import * #导入所有的request,urllib相当于一个文件夹,用到它里面的方法requestfrom lxml impor ...

  6. Win10系列:C#应用控件基础20

    SemanticZoom控件 SemanticZoom控件由相互关联的缩小视图和放大视图所组成,缩小视图用来显示内容的索引,放大视图可以用来显示内容的详细信息,用户可以根据阅读需要在两种视图之间自由切 ...

  7. SQL DELETE 语句详解

    SQL DELETE 语句详解   DELETE 语句 DELETE 语句用于删除表中的行. 语法 DELETE FROM 表名称 WHERE 列名称 = 值 Person: LastName Fir ...

  8. Jmeter对HTTP请求压力测试、并发测试的简单使用方法

    对于服务器性能测试这块的经验更是少得可以忽略.迫使不得不让我们去尝试了解测试的知识. 首先我们的需求场景如下: 服务器硬件:(只有一台) 系统:Windows 2003 WebServer:Tomca ...

  9. Linux目录结构下部

    第1章 linux目录结构 (linux必知必会的文件或目录) 1.1 在linux下面如何安装软件 yum install tree 1.2 linux无法上网了怎么办? [root@oldboye ...

  10. Linux3.10.0块IO子系统流程(5)-- 为SCSI命令准备聚散列表

    SCSI数据缓冲区组织成聚散列表的形式.Linux内核中表示聚散列表的基本数据结构是scatterlist,虽然名字中有list,但它只对应一个内存缓冲区,聚散列表就是多个scatterlist的组合 ...