题解 | #滑动窗口的最大值#
滑动窗口的最大值
http://www.nowcoder.com/practice/1624bc35a45c42c0bc17d17fa0cba788
```function maxInWindows(num, size)
{
// write code here
//设置两个指针i和j,i指向0,j指向size-1,取出i到j之间几个数放进临时数组,用求得最大值,然后i++,j++,直到j===len-1.
let len = num.length
if(size>len||size===0){return []}
let i=0
let j=size-1
let resArr=[]
while(j<len){
let temp = num.slice(i,j+1)
resArr.push(Math.max(...temp))
i++
j++
}
return resArr
}
module.exports = {
maxInWindows : maxInWindows
};