当前位置:网站首页>674. longest continuous increasing sequence force buckle JS
674. longest continuous increasing sequence force buckle JS
2022-07-01 03:52:00 【Big drumsticks are best】
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.
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 .
### Their thinking
Here is the solution
Greedy Algorithm
a by b Maximum value of previous value
b Every time I meet the next one smaller than this, I will start a new wave
### Code
```javascript
/**
* @param {number[]} nums
* @return {number}
*/
var findLengthOfLCIS = function(nums) {
let a=1,b=1
let len=nums.length
for(let i=0;i<len-1;i++){
if(nums[i]<nums[i+1]){
b+=1
a=Math.max(a,b)
}
else{
b=1
}
}
return a
};
```
边栏推荐
- 【TA-霜狼_may-《百人计划》】1.2.2 矩阵计算
- The problem of integrating Alibaba cloud SMS: non static methods cannot be referenced from the static context
- 【TA-霜狼_may-《百人計劃》】2.3 常用函數介紹
- [deep learning] activation function (sigmoid, etc.), forward propagation, back propagation and gradient optimization; optimizer. zero_ grad(), loss. backward(), optimizer. Function and principle of st
- RSN:Learning to Exploit Long-term Relational Dependencies in Knowledge Graphs
- 访问阿里云存储的图片URL实现在网页直接预览略缩图而不直接下载
- All in one 1086: Jiaogu conjecture
- 有效的 @SuppressWarnings 警告名称
- 171. excel table column No
- Blueprism registration, download and install -rpa Chapter 1
猜你喜欢

SEM of C language_ Tvariable type

【TA-霜狼_may-《百人计划》】1.4 PC手机图形API介绍

程序员女友给我做了一个疲劳驾驶检测

Complete knapsack problem

静态库使用MFC和共享库使用MFC的区别

Appium自动化测试基础--补充:C/S架构和B/S架构说明

Network metering - application layer

Cygwin的下载和安装配置

Use selenium automated test tool to climb the enrollment score line and ranking of colleges and universities related to the college entrance examination
![[TA frost wolf \u may- hundred talents plan] 1.2.3 MVP matrix operation](/img/4e/8cf60bc816441967c04f97c64685a1.png)
[TA frost wolf \u may- hundred talents plan] 1.2.3 MVP matrix operation
随机推荐
392. judgment subsequence
241. Design priorities for operational expressions
【TA-霜狼_may-《百人计划》】1.2.1 向量基础
How to display scrollbars on the right side of the background system and how to solve the problem of double scrollbars
【EI会议】2022年国际土木与海洋工程联合会议(JCCME 2022)
Online public network security case nanny level tutorial [reaching out for Party welfare]
[TA frost wolf \u may- hundred people plan] 1.3 secret of texture
165. compare version numbers
“目标检测“+“视觉理解“实现对输入图像的理解
【历史上的今天】6 月 30 日:冯·诺依曼发表第一份草案;九十年代末的半导体大战;CBS 收购 CNET
5. [WebGIS practice] software operation - service release and permission management
Millet College wechat scanning code login process record and bug resolution
【TA-霜狼_may-《百人计划》】1.3纹理的秘密
165. 比较版本号
程序员女友给我做了一个疲劳驾驶检测
166. 分数到小数
【TA-霜狼_may-《百人计划》】1.2.3 MVP矩阵运算
[TA frost wolf \u may- hundred talents plan] 1.2.3 MVP matrix operation
283.移动零
171. Excel 表列序号