题解 | #Redraiment的走法#

Redraiment的走法

http://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa

alt

readline()
const arr=readline().split(' ').map(item=>parseInt(item))
const res=[]
arr.forEach((item,idx)=>{
    let maxStep=0
    for(let i=0;i<idx;i++){
        if(arr[i]<item && res[i]>maxStep){ maxStep=res[i]}
    }
    res.push(maxStep+1)
})
print(Math.max(...res))

全部评论
maxStep=res[i]这里是不是应该为 maxStep=Math.max(maxStep,res[i])要好一点。
点赞 回复 分享
发布于 2022-12-18 20:09 重庆

相关推荐

野猪不是猪🐗:还是太卑微了,什么叫放弃本次面试应该说经过评估,贵公司与自己不匹配,决定不再推进后续流程
点赞 评论 收藏
分享
评论
7
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务