```js const arr = [101,19,12,51,32,7,103,8]; ``` **问题一:** 找出连续最大升序的数量 **问题二:** 找出不连续最大升序的数量
Activity
syc666 commentedon Nov 4, 2020
问题一
问题二
sisterAn commentedon Nov 4, 2020
解答问题一:
leetcode
解答问题二:
teal-front commentedon Nov 5, 2020
问题一: 找出连续最大升序的数量
wenfeihuazha commentedon Nov 6, 2020
mingju0421 commentedon Nov 6, 2020
ohion commentedon Nov 10, 2020
ohion commentedon Nov 10, 2020
xllpiupiu commentedon Oct 5, 2021
测试数据let arr = [101,19,12,34,51,32,7,103,8,104,1,105,2,106]
结果是6 实际结果应该是7吧 12 34 51 103 104 105 106
xllpiupiu commentedon Oct 5, 2021
xllpiupiu commentedon Oct 5, 2021
AlexZhang11 commentedon May 24, 2024
function fn(nums){
let maxcontinueUpCount=1,maxcontinueUpCountValue = 1;
let maxBreakUpCount= 1,maxBreakUpCountValue =1
let i = 1
while(i<nums.length){
if(nums[i]>nums[i-1]){
if(maxBreakUpCountValue<maxBreakUpCount){
maxBreakUpCountValue = maxBreakUpCount
}
maxBreakUpCount=1
maxcontinueUpCount++
}else{
if(maxcontinueUpCountValue<maxcontinueUpCount){
maxcontinueUpCountValue = maxcontinueUpCount
}
maxcontinueUpCount = 1
maxBreakUpCount++
}
i++
}
return {
maxBreakUpCountValue,
maxcontinueUpCountValue
}
}
console.log(fn([101,19,12,51,32,7,103,8]))