剑指offer 滑动窗口的最大值 Posted on 2019-03-06 | 方法方法1:bisect12345678910111213141516171819202122232425# -*- coding:utf-8 -*-class Solution: def maxInWindows(self, num, size): # write code here import bisect if size==0 or size>len(num): return [] elif size==1: return map(float,num) self.window=num[:size] self.window.sort() res=[] res.append(self.window[-1]) i=1 j=size while j<len(num): self.window.remove(num[i-1]) bisect.insort_left(self.window,num[j]) res.append(self.window[-1]) i+=1 j+=1 return res