LearnPy Hub
← Arena
AdvancedRating 1900

Median of Every Window

For every block of k consecutive numbers, print its median (for even k, the smaller of the two middle numbers).

Input

n and k, then n integers.

Output

n − k + 1 integers.

Sample 1

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

Sample 2

Input
4 4
1 2 3 4
Output
2
solution.py
Output appears here
Median of Every Window · Python Arena problem · LearnPy Hub