Given an unsorted array of integers, find the length of longest continuousincreasing 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(object):
  2. def findLengthOfLCIS(self, nums):
  3. """
  4. :type nums: List[int]
  5. :rtype: int
  6. """
  7. if not nums:
  8. return 0
  9. ans=1
  10. count=1
  11. n=len(nums)
  12. i=1
  13. while i<n:
  14. if nums[i-1]<nums[i]:
  15. count+=1
  16. else:
  17. if ans<count:
  18. ans=count
  19. count=1
  20. i+=1
  21. if ans<count:
  22. return count
  23. 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. RabbitMQ详解(三)------RabbitMQ的五种模式

    RabbitMQ详解(三)------RabbitMQ的五种模式 1.简单队列(模式) 上一篇文章末尾的实例给出的代码就是简单模式. 一个生产者对应一个消费者!!! pom.xml ​ 必须导入Rab ...

  2. centos7 keepalived 配置高可用

    ! Configuration File for keepalived global_defs { notification_email { xaioqiang.he@xinboxinmo.com } ...

  3. style,ng-style, ng-attr-style的对比

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...

  4. UVA1388 Graveyard

    思路 就是对于每个点,找出离他最近的目标点的距离 我使用了上取整和下取整实现,蓝书上的实现方法是坐标系缩放,每个点的目标位置就是它四舍五入的结果 具体证明见蓝书 代码 #include <cst ...

  5. 编码原则 之 Persistence Ignorance

    原文 The principle of Persistence Ignorance (PI) holds that classes modeling the business domain in a ...

  6. Mac OS X 清除DNS缓存

    参考: Flushing your DNS cache in Mac OS X and Linux Mac OS X 清除DNS缓存 根据Mac OS X操作系统的版本选择以下命令: Mac OS X ...

  7. 关于MVC RouteExistingFiles疑问后续

    前两天写了<关于MVC RouteExistingFiles疑问>,本来希望寻求大佬快速解答,奈何无人问津. 只能查看.NET 源代码,可以使用反编译工具(我用IL spy),也可以在线查 ...

  8. SAP Fiori Client

    iPhone资源->iPhone商务软件 SAP Fiori Client 固件要求:需要 iOS 9.0 或更高版本.与 iPhone.iPad 和 iPod touch 兼容. 利用适用于 ...

  9. 『TensorFlow』SSD源码学习_其七:损失函数

    Fork版本项目地址:SSD 一.损失函数介绍 SSD损失函数分为两个部分:对应搜索框的位置loss(loc)和类别置信度loss(conf).(搜索框指网络生成的网格) 详细的说明如下: i指代搜索 ...

  10. xlwt 写sheet xls 文件

    import xlwtworkbook = xlwt.Workbook()#创建bookworksheet = workbook.add_sheet('My Sheet') #添加sheet#背景色的 ...