Problem statement
This is a design drill rather than a single question. A fixed frame asks for a statistic on every window, and the statistic is often more than a total: a distinct count, a peak, a count of values that appear once.
The task is to decide which of those can ride along a slide, where one value leaves and one arrives, and to pay a rebuild only where a statistic cannot be undone.
Examples
Inputnums = [2, 1, 5, 1, 3, 2], k = 3
Output1 rebuild
The peak is 5 until the last slide drops it, and only that slide rebuilds it.
Inputnums = [1, 2], k = 3
Output0 rebuilds
No window exists, so no slide ever runs.
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