Google

Anonymous User
417
Oct 13, 2025

Given a list of integers and a fixed-size window (e.g., size = 5), determine the minimum number of window moves required to cover all elements in the list. The list cannot be reordered, and the window must slide forward to cover consecutive segments of the list. Each window placement covers a contiguous subset of the list up to the window size.
Examples:

Input: [1, 2, 3, 4, 5, 8, 9, 10, 11, 12], window size = 5
Output: 1
Explanation: The window can cover [1, 2, 3, 4, 5] in the first position and [8, 9, 10, 11, 12] after one move (shift to index 5). Total moves = 1.
Input: [100, 1, 2, 3, 9, 12], window size = 5
Output: 2
Explanation: The window covers [100] (1 element) in the first position, [1, 2, 3] (3 elements) in the second position after one move, and [9, 12] (2 elements) after another move. Total moves = 2.

Comments (3)