1 # -*- coding:utf-8 -*- 2 class Solution: 3 def maxInWindows(self, num, size): 4 # write code here 5 res = [] 6 # 特殊值 7 if size > len(num) or size<=0: 8 return res 9 for i in range(size-1,len(num),1): 10 res.append(max(num[i-size+1:i+1])) 11 return res 12
解法2:
原文:https://www.cnblogs.com/shuangcao/p/13159333.html