题解 | #滑动窗口的最大值#
滑动窗口的最大值
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
};
#我的实习求职记录#
查看17道真题和解析