LearnPy Hub
← Iterators & Generators problems
Hard

Maximum of Every Window

Write a generator window_max(nums, k) that yields the maximum of every run of k neighbours, using a collections.deque of positions whose values decrease. Read integers and k and print the yielded values on one line.

Input

Integers, then k.

Output

One line.

Sample 1

Input
1 3 -1 -3 5 3 6 7
3
Output
3 3 5 5 6 7

Sample 2

Input
4 2
1
Output
4 2
solution.py
Output appears here
Maximum of Every Window · Python practice problem · LearnPy Hub