Given an integer array nums and integer k, find a contiguous subarray of length k that has the maximum average. Return this maximum average.
Use a fixed-size sliding window of size k. Compute the initial sum of first k elements, then slide the window by subtracting the leftmost element and adding the new rightmost element.
- Compute sum of first k elements.
- Slide from index k to n-1: add nums[i], subtract nums[i-k].
- Track maximum sum throughout.
- Return maxSum / k as double.
- Time Complexity: O(N)
- Space Complexity: O(1)