当前位置:网站首页>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;
}边栏推荐
- Zoom with mouse wheel
- PHP function file_ get_ Contents and memory mapping of operating system
- Along with the notes: methods simulating array like classes
- Daily question 1: remove elements
- Two fresh students: one is practical and likes to work overtime, and the other is skilled. How to choose??
- The magical zero knowledge proof can not only keep secrets, but also make others believe you!
- Structure of the actual combat battalion | module 5
- Common mistakes in software testing
- mysql 8.0以上报2058 解决方式
- 12.物体检测Mask-Rcnn
猜你喜欢

Two fresh students: one is practical and likes to work overtime, and the other is skilled. How to choose??

HandlerThread使用及原理

Typescript -- Section 2: variable declaration

How to calculate the income tax of foreign-funded enterprises

Typescript -- Section 1: basic types

Technology sharing | software development process that you must understand if you want to get started with testing
![[image registration] improved SAR image registration based on sar-sift with matlab code](/img/69/4e78c6cef45b2e4d133222a4372e43.jpg)
[image registration] improved SAR image registration based on sar-sift with matlab code

Comics | goodbye, postman! One stop collaboration makes apipost more fragrant!

How the slip ring motor works
![[leetcode] 522. 最长特殊序列 II 暴力 + 双指针](/img/88/3ddeefaab7e29b8eeb412bb5c3e9b8.png)
[leetcode] 522. 最长特殊序列 II 暴力 + 双指针
随机推荐
Résumé de Manon, 25 ans, diplômé en trois ans
PR 2021 quick start tutorial, how to use audio editing in PR?
12.物體檢測Mask-Rcnn
The company has a new Post-00 test paper king. The old oilman said that he could not do it. He has been
Pinhole camera with added lens
12. object detection mask RCNN
6.28 learning content
JDBC连接、断开数据库的封装
[leetcode] 522. 最长特殊序列 II 暴力 + 双指针
用户登录(记住用户)&用户注册(验证码) [运用Cookie Session技术]
Report on the convenient bee Lantern Festival: the first peak sales of pasta products this year; prefabricated wine dumplings became the winners
Typescript -- Section 1: basic types
[image registration] SAR image registration based on particle swarm optimization Improved SIFT with matlab code
Single machine multi instance MySQL master-slave replication
Give you a project, how will you carry out performance testing (I)
毕业三年的25岁码农总结
每日一题: 数组中数字出现的次数
Haskell 配置 VS code 开发环境 (2022年6月)
12. Détection d'objets Mask rcnn
光纤滑环价格过高的原因