Maximum Average Subarray I

Sliding window · Reuse a fixed-size window · Easy · about 16 min

Why it matters

A sliding window avoids recalculating overlapping ranges.

How it connects

Two pointers moved toward each other. Now they move together and keep a window size.

Try first

Find the sum of the first window, then describe exactly what changes when it shifts right once.

Interview cue

The window update is constant work, so every value is processed at most twice.