记录一下,很有意思
# -*- coding:utf-8 -*- class Solution: def maxInWindows(self, num, size): # write code here if not num or not size:return None //前提条件 lenth = len(num) - size + 1 //这里正好是窗口的大小 res =[] for i in range(lenth): //range很重要 max1 = max(num[i:size+i]) //移动的点 res.append(max1) return res