题解 | #滑动窗口的最大值#

滑动窗口的最大值

https://www.nowcoder.com/practice/1624bc35a45c42c0bc17d17fa0cba788

function maxInWindows(num, size)
{
    // write code here
    if(num.length < size || size == 0){
        return [];
    }
    let res = []
    let i = 0;
    while(i <= num.length - size){
        let max = -100000
        for(let j = i;j<i+size;j++){
            if(num[j] > max){
                max = num[j];
            }
        }
        i += 1;
        res.push(max);
    }
    return res;
}
module.exports = {
    maxInWindows : maxInWindows
};

#我的实习求职记录#
全部评论

相关推荐

是每个人事都这样与找工作的人这样沟通吗?正常询问不可以吗
据说名字越长别人越关注你的昵称我觉得我要被关注了:excal 我还真不会
点赞 评论 收藏
分享
05-23 20:31
已编辑
武汉大学 Java
内向的柠檬精在研究求职打法:注意把武大标粗标大 本地你俩不是乱杀
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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