[LeetCode&Python] Problem 674. Longest Continuous Increasing Subsequence
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的更多相关文章
- 【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 ...
随机推荐
- JS(JavaScript)的初了解2(更新中···)
1.parseInt() 整数型 字符串中的数字取整 遇到第一个是非数字的字节就结束了. 2.parseFloat 浮点型 字符中的数字取整数和小数,有两个小数点的话第二个小数点无效第二个小数点 ...
- react-router 4.0(四)页面跳转验证提示
import React from 'react' import ReactDOM from 'react-dom' import { HashRouter, Route, Link, Prompt ...
- Character Encoding in .NET
https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-encoding#Encodings Characters ...
- mvc 之 配置EF+oralce
只需要在项目中加载nuGet包就可以了 操作:工具--nuGet包管理器--程序包管理器控制台 在 PM>处输入 install-package entityframework 加载sqlser ...
- 剑指offer 01:二维数组中的查找
题目描述 在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数 ...
- tcp协议以及socket介绍
壹:tcp协议:可靠传输 一: 3次握手,建立链接:4次挥手,断开链接 3次握手,建立链接:图解 ,这样双向通路就建立完成了. 在建立链接时,并没有数据传输,所以中间两部可以合在一起,也就是3次握手, ...
- Linux下postgres9.4 版本的单机版安装小笔记
1.添加RPMyum install https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-7-x86_64/pgdg-redha ...
- Kafka学习之二 Kafka安装和使用
部署环境Linux(Centos 6.5),JDK 1.8.0,zookeeper-3.4.12,kafka_2.11-2.0.0. 1. 单机环境 官方建议使用JDK 1.8版本,因此本文使 ...
- javascript里文字选中/选中文字
一.获取/清除选中的文字 //获取选中的文字 document.getElementById("get").onclick = function () { var txt = wi ...
- Matlab:高阶常微分三种边界条件的特殊解法(隐式Euler)
函数文件1: function b=F(f,x0,u,h) b(1,1)=x0(1)-h*x0(2)-u(1); b(2,1)=x0(2)+h*x0(1)^2-u(2)-h*f; 函数文件2: fun ...