当前位置:网站首页>674. longest continuous increasing sequence
674. longest continuous increasing sequence
2022-06-29 00:37:00 【mrbone9】
Address :
Power button
https://leetcode-cn.com/problems/longest-continuous-increasing-subsequence/
subject :
Given an unordered array of integers , Find the longest and Successive increasing subsequences , And return the length of the sequence .
Successive increasing subsequences It can be made up of two subscripts l and r(l < r) determine , If for each l <= i < r, There are nums[i] < nums[i + 1] , So the subsequence [nums[l], nums[l + 1], ..., nums[r - 1], nums[r]] It's a continuous increasing subsequence .
Example 1:
Input :nums = [1,3,5,4,7]
Output :3
explain : The longest continuous increasing sequence is [1,3,5], The length is 3.
Even though [1,3,5,7] It's also a subsequence of ascending order , But it's not continuous , because 5 and 7 In the original array is 4 separate .
Example 2:
Input :nums = [2,2,2,2,2]
Output :1
explain : The longest continuous increasing sequence is [2], The length is 1.
Tips :
1 <= nums.length <= 104
-109 <= nums[i] <= 109
source : Power button (LeetCode)
link :https://leetcode-cn.com/problems/longest-continuous-increasing-subsequence
Copyright belongs to the network . For commercial reprint, please contact the official authority , Non-commercial reprint please indicate the source .
Ideas :
Is to compare one by one , Record the maximum length
int findLengthOfLCIS(int* nums, int numsSize){
int i;
int idx = 0;
int maxlen = 1;
for(i=1; i<numsSize; i++)
{
if(nums[i] <= nums[i-1])
{
idx = i;
}
maxlen = fmax(maxlen, i-idx+1);
}
return maxlen;
}边栏推荐
- 12. Détection d'objets Mask rcnn
- 利用verilogA模块采样
- Typescript -- Section 7 enumeration
- [image registration] improved SAR image registration based on sar-sift with matlab code
- Daily practice: delete duplicates in the ordered array
- [Gym 102423]-Elven Efficiency | 思维
- [communication] wide band source DOA estimation method based on incoherent signal subspace (ISM)
- Structure of the actual combat battalion | module 5
- Common mistakes in software testing
- mysql 8.0以上报2058 解决方式
猜你喜欢

【leetcode】17. Letter combination of telephone number

11. target segmentation
JVM底层又是如何实现synchronized的

每日一题:移除元素

The magical zero knowledge proof can not only keep secrets, but also make others believe you!
![[image registration] SAR image registration based on particle swarm optimization Improved SIFT with matlab code](/img/b5/02979b50db885f0606dce455182ac4.jpg)
[image registration] SAR image registration based on particle swarm optimization Improved SIFT with matlab code

每日一题:消失的数字

旋轉接頭安裝使用注意事項

Reasons for high price of optical fiber slip ring

Technology sharing | software development process that you must understand if you want to get started with testing
随机推荐
Typescript-- section 4: Functions
Install MySQL on Windows platform (with Navicat premium 12 "using" tutorial)
Roson's QT journey 80 qurl class
ES6 module
如果你会玩这4个自媒体运营工具,副业收入6000+很轻松
JDBC连接、断开数据库的封装
10、YOLO系列
旋转接头安装使用注意事项
The company has a new Post-00 test paper king. The old oilman said that he could not do it. He has been
Is the fund reliable and safe
运营级智慧校园系统源码 智慧校园小程序源码+电子班牌+人脸识别系统
[200 opencv routines] 101 adaptive median filter
pinhole camera model
Program environment and pretreatment
[gym 102423]-elven efficiency | thinking
Introduction to JVM working principle
Is pension insurance a financial product? Where is the expected return?
Remove HTML tags from Oracle
[Gym 102423]-Elven Efficiency | 思维
WPF implementation calls local camera~