题目: https://leetcode-cn.com/problems/sliding-window-maximum/
1.暴力法
遍历数组
依次遍历每个区间内的最大值,放入数组中
/**
* @param {number[]} nums
* @param {number} k
* @return {number[]}
*/
var maxSlidingWindow = function(nums, k) {
if(nums === 0) return []
if(k === 1) return nums
let arr = []
for(let i = 0; i <= nums.length - k; i++){
let max = Number.MIN_SAFE_INTEGER
for(let j = i; j < i+k; j++){
max = Math.max(max, nums[j])
arr.push[max]
}
}
return arr
};
2.滑动窗口最大值