Problem statement
Given an array and a window size k, report the smallest value inside every window of k consecutive values.
The walk is the maximum walk with both value comparisons flipped, because a value beaten by a smaller later one can never be the minimum of a window containing both.
Examples
Input[4, 2, 12, 11, -5, 8], k = 3
Output[2, 2, -5, -5]
The 2 at index 1 wins the first two windows, then -5 wins everything after it.
Input[9, 7, 5], k = 3
Output[5]
One window, and the falling values leave only the smallest at the front.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing