题解 | #滑动窗口的最大值#
滑动窗口的最大值
https://www.nowcoder.com/practice/1624bc35a45c42c0bc17d17fa0cba788
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型一维数组 * @param size int整型 * @return int整型一维数组 */ public List<int> maxInWindows (List<int> num, int size) { // write code here if (size == 0 || size > num.Count) return new List<int>(); List<int> res = new List<int>(); int left = 0; int right = left + size - 1; for (; right <= num.Count - 1 ; left++, right++) { int max = int.MinValue; for (int i = left; i <= right; i++) { if (num[i] > max) { max = num[i]; } } res.Add(max); } return res; } }#滑动窗口双指针问题#