滑动窗口最大值数组_python3
生成窗口最大值数组
http://www.nowcoder.com/questionTerminal/b316c7f9617744b98fa311ae29ac516c
单调队列
def solve(l, n, k): index = [] for i in range(n): while index and l[index[-1]] < l[i]: index.pop(-1) index.append(i) while index and i - index[0] >= k: index.pop(0) print(index) if i >= k - 1: if i != n - 1: print(l[index[0]], end = ' ') else: print(l[index[0]]) while True: try: n, k = map(int, input().split()) l = list(map(int, input().split())) solve(l, n, k) except EOFError: break