class Solution: def maxInWindows(self , num: List[int], size: int) -> List[int]: res = [] #窗口大于数组长度的时候,返回空 if size <= len(num) and size != 0: #数组后面要空出窗口大小,避免越界 for l in range (len(num) - size + 1): r = l + size - 1 if l == 0: maxn = max(num[l : r+1]) res.append(maxn) else: if num[l-1] < maxn and num[r] < maxn: res.append(maxn) continue elif num[l-1] == maxn: maxn = max(num[l:r+1]) res.append(maxn) elif num[r] >= maxn: maxn = num[r] res.append(maxn) return res