We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原题链接:https://leetcode-cn.com/problems/sliding-window-maximum/
解题思路:
参考了官方题解的方法一。
/** * @param {number[]} nums * @param {number} k * @return {number[]} */ var maxSlidingWindow = function (nums, k) { let result = []; // 遍历滑块的起始点 for (let i = 0; i < nums.length - k + 1; i++) { let max = nums[i]; // 按照滑块宽度,查找后续元素,并对比最大值 for (let j = i + 1; j < i + k; j++) { max = Math.max(max, nums[j]); } // 比对完滑块所有元素之后,将最大值存入result result.push(max); } return result; };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原题链接:https://leetcode-cn.com/problems/sliding-window-maximum/
解题思路:
参考了官方题解的方法一。
The text was updated successfully, but these errors were encountered: