Sliding Window Minimum
InterviewTime limit2.4sMemory limit512 MB
Print the minimum of each window of length L ending at every position of the array.
- Level
Medium4 of 10
- Topics
- Sliding window, Queue
- Solved
- No attempts yet
Problem
You are given numbers and a number .
Let be the minimum of through . That is, is the smallest value in the window of length that ends at position . No with an index of or less exists, so ignore those indices when computing . When the window is shorter, and is the minimum of through .
Write a program that prints through .
Input
The first line contains and . ()
The second line contains the numbers , separated by spaces. ()
Output
On the first line, print through in order, separated by spaces.