1def max_sliding_window(nums, k):
2 res = []
3 q = []
4 left = 0
5 for right in range(len(nums)):
6 while q and nums[q[-1]] < nums[right]:
7 q.pop()
8 q.append(right)
9 if left > q[0]:
10 q.pop(0)
11 if right >= k - 1:
12 res.append(nums[q[0]])
13 left += 1
14 return res