DSA · Reimagined
Arrays easy time O(n) space O(1)

Sliding Window (Max Sum)

For a window of size k, sum the first window, then slide: add the entering element and subtract the leaving one. No value is ever re-summed.

2
0
1
1
5
2
1
3
3
4
2
5
8
6
1
7

First window [0..2] sums to 8.

k 3sum 8best 8
1 / 9

Practice

Machine twin: /dsa-viz-v2/sliding-window.json — the full deterministic run as structured data.