An array contains 5 elements. How many contiguous windows of length 3 does it have?
Answer & explanation
Answer: 3
A window of size k in an array of length L has L - k + 1 valid starting positions.
Practice sliding windows with self-contained questions. Check your answer, then use the explanation to understand the reasoning.
Answer: 3
A window of size k in an array of length L has L - k + 1 valid starting positions.