Fixed window — instead of re-summing from scratch each time, slide: add incoming element, subtract outgoing.
This reduces the naïve O(nk) approach to O(n).
Max sum ÷ k = max avg (dividing by a constant k preserves order).
Summing every window from scratch costs O(n) times k. Neighbouring windows share almost all their numbers, so that work is repeated.
Since every window has the same length, the largest average is just the largest sum. Compute the first window once. Then slide: add the number entering on the right, and subtract the one leaving on the left.
A fixed window slides by adding the new number and removing the oldest. Same length means the largest average is the largest sum.
Run the animation above on your own input, or watch the 1:31 video explanation of Maximum Average Subarray I with a dry run and Java code.