python3 滑动窗口的最大值
滑动窗口的最大值
http://www.nowcoder.com/questionTerminal/1624bc35a45c42c0bc17d17fa0cba788
python 切片它不香吗?
# -*- coding:utf-8 -*- class Solution: def maxInWindows(self, num, size): # write code here if not num or not size: return [] result = [] length = len(num)-size+1 for i in range(length): max_val = max(num[i:size+i]) result.append(max_val) return result