当前位置:网站首页>Leetcode- longest continuous increasing sequence - simple
Leetcode- longest continuous increasing sequence - simple
2022-06-13 05:50:00 【AnWenRen】
title :674 The longest continuous increasing sequence - Simple
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
Code Java
public int findLengthOfLCIS(int[] nums) {
int count = 1;
int ans = 1;
for (int i = 1; i < nums.length; i++) {
if (nums[i] > nums[i - 1]) {
count ++;
} else {
count = 1;
}
if (count > ans) {
ans = count;
}
}
return ans;
}
边栏推荐
- 移动端适配方案
- Input a number and output each digit from high to low
- Building a stand-alone version of Nacos series
- Interrupt processing
- About the solution of pychart that cannot be opened by double clicking
- 使用cmake交叉编译helloworld
- Mobile end adaptation scheme
- What happens when the MySQL union index ABC encounters a "comparison operator"?
- Browser screenshot method (long screenshot, node screenshot, designated area screenshot)
- Leetcode- first unique character in string - simple
猜你喜欢

Quartz database storage

零拷贝技术

20 flowable container (event sub process, things, sub process, pool and pool)

OpenGL馬賽克(八)

Agile conflicts and benefits

Ffmpeg download suffix is Video files for m3u8

How to view tongweb logs correctly?

18 flowable task manualtask and receivetask

为什么那么多人讨厌A-Spice

Interrupt processing
随机推荐
Browser screenshot method (long screenshot, node screenshot, designated area screenshot)
How to Algorithm Evaluation Methods
Application virtual directory static resource configuration on tongweb
10 signalstartevent and signalcatchingevent of flowable signal events
Parallelgateway and exclusivegateway of 14 gateways
Find out the missing numbers from the natural numbers arranged in order from 0 to 100, and the solution provides
The problem of distinguishing and sharing sessions for multiple applications in tongweb
Concurrent programming -- source code analysis of thread pool
Missing tag identification in cots RFID systems: bringing the gap between theory and Practice
AUTOSAR实战教程pdf版
MySQL fuzzy query and sorting by matching degree
Randomly fetch data from the list
MongoDB 多字段聚合Group by
Leetcode- complement of numbers - simple
Input a number and output each digit from high to low
Explanation of sentinel series' features, composition and deployment
Service fusing and degradation of Note Series
= = relation between int and integer
Leetcode- longest palindrome string - simple
Leetcode judge subsequence simple