[LeetCode&Python] Problem 674. Longest Continuous Increasing Subsequence
Given an unsorted array of integers, find the length of longest continuous
increasing 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的更多相关文章
- 【Leetcode_easy】674. Longest Continuous Increasing Subsequence
problem 674. Longest Continuous Increasing Subsequence solution class Solution { public: int findLen ...
- leetcode300. Longest Increasing Subsequence 最长递增子序列 、674. Longest Continuous Increasing Subsequence
Longest Increasing Subsequence 最长递增子序列 子序列不是数组中连续的数. dp表达的意思是以i结尾的最长子序列,而不是前i个数字的最长子序列. 初始化是dp所有的都为1 ...
- 【LeetCode】674. Longest Continuous Increasing Subsequence 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 动态规划 空间压缩DP 日期 题目地址:https: ...
- [LeetCode] 674. Longest Continuous Increasing Subsequence 最长连续递增序列
Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...
- LeetCode 674. Longest Continuous Increasing Subsequence (最长连续递增序列)
Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...
- [Leetcode]674. Longest Continuous Increasing Subsequence
Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...
- 674. Longest Continuous Increasing Subsequence@python
Given an unsorted array of integers, find the length of longest continuous increasing subsequence (s ...
- LeetCode 674. Longest Continuous Increasing Subsequence最长连续递增序列 (C++/Java)
题目: Given an unsorted array of integers, find the length of longest continuous increasing subsequenc ...
- 674. Longest Continuous Increasing Subsequence最长连续递增子数组
[抄题]: Given an unsorted array of integers, find the length of longest continuous increasing subseque ...
随机推荐
- RabbitMQ详解(三)------RabbitMQ的五种模式
RabbitMQ详解(三)------RabbitMQ的五种模式 1.简单队列(模式) 上一篇文章末尾的实例给出的代码就是简单模式. 一个生产者对应一个消费者!!! pom.xml 必须导入Rab ...
- centos7 keepalived 配置高可用
! Configuration File for keepalived global_defs { notification_email { xaioqiang.he@xinboxinmo.com } ...
- style,ng-style, ng-attr-style的对比
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...
- UVA1388 Graveyard
思路 就是对于每个点,找出离他最近的目标点的距离 我使用了上取整和下取整实现,蓝书上的实现方法是坐标系缩放,每个点的目标位置就是它四舍五入的结果 具体证明见蓝书 代码 #include <cst ...
- 编码原则 之 Persistence Ignorance
原文 The principle of Persistence Ignorance (PI) holds that classes modeling the business domain in a ...
- Mac OS X 清除DNS缓存
参考: Flushing your DNS cache in Mac OS X and Linux Mac OS X 清除DNS缓存 根据Mac OS X操作系统的版本选择以下命令: Mac OS X ...
- 关于MVC RouteExistingFiles疑问后续
前两天写了<关于MVC RouteExistingFiles疑问>,本来希望寻求大佬快速解答,奈何无人问津. 只能查看.NET 源代码,可以使用反编译工具(我用IL spy),也可以在线查 ...
- SAP Fiori Client
iPhone资源->iPhone商务软件 SAP Fiori Client 固件要求:需要 iOS 9.0 或更高版本.与 iPhone.iPad 和 iPod touch 兼容. 利用适用于 ...
- 『TensorFlow』SSD源码学习_其七:损失函数
Fork版本项目地址:SSD 一.损失函数介绍 SSD损失函数分为两个部分:对应搜索框的位置loss(loc)和类别置信度loss(conf).(搜索框指网络生成的网格) 详细的说明如下: i指代搜索 ...
- xlwt 写sheet xls 文件
import xlwtworkbook = xlwt.Workbook()#创建bookworksheet = workbook.add_sheet('My Sheet') #添加sheet#背景色的 ...