The sliding window is the umbrella technique beneath much of streaming: maintain a contiguous window over the stream, growing it from the right and shrinking it from the left to preserve some invariant (a sum below a cap, no repeated element, at most k distinct). Because each endpoint only ever moves forward, the whole scan is one pass — a window that looks quadratic (all subarrays) resolved in O(n). Here the fixed-width case: over a stream, keep the running sum of the current window and report the maximum window sum, adding the entrant and dropping the leaver so the work per step never depends on the window's width.
A stream and a window of 2. The demo maintains the running window sum and reports the maximum — each endpoint moving only forward: live demo
“Checking every subarray is quadratic.” — when the endpoints only move forward, a sliding window checks the relevant ones in a single linear pass. The caterpillar crawls once. cited
A window that only ever crawls forward; the invariant held as it grows and shrinks. Every relevant span, in one pass. sliding window
On the canonical compiler, the maximum window-2 sum over [1,3,2,5] is 7 (the window [2,5]):