Workspace Fixed Window
0d
Problem-solving patterns

Fixed-Width Window

Update the summary of exactly k consecutive elements.

Recognition signal

The required interval length is fixed.

Method

Build the first summary, then remove the departing item and add the arriving one.

Worked example

Width two over [5, −3, 9] yields totals 2 and 6.

Common mistake

Selecting zero as the initial best loses windows with all-negative sums.