Find a contiguous subarray whose length is equal to k that has the maximum average value in O(N) linear time.
You are given an integer array `nums` consisting of `n` elements, and an integer `k`. Find a contiguous subarray whose length is equal to `k` that has the maximum average value and return this value.
Invariant: windowSum represents nums[i-k+1 ... i].
Update only boundary elements instead of recomputing full range.
Bottleneck: Reduces compute by factor of K.
Find a contiguous subarray whose length is equal to k that has the maximum average value in O(N) linear time.
You are given an integer array `nums` consisting of `n` elements, and an integer `k`. Find a contiguous subarray whose length is equal to `k` that has the maximum average value and return this value.
Invariant: windowSum represents nums[i-k+1 ... i].
Update only boundary elements instead of recomputing full range.
Bottleneck: Reduces compute by factor of K.
Initialized sliding window with fixed size k = 4. Beginning window expansion.