Given an integer array and an integer , find the contiguous subarray of length that has the maximum average value.
You're looking at the simplest fixed-window problem. You maintain the sum of the current window. When sliding, add the new element and subtract the old one. Read the problem. The constraints allow but not .