IntermediateRating 1400
Maximum in Every Window
For every block of k consecutive numbers, print its maximum. n can be 10⁵, so a slow solution won't pass.
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
3 3 5 5 6 7
Sample 2
Input
1 1 4
Output
4
Output appears here