Maximum Average Subarray
Look at every stretch of exactly k consecutive items in nums. Return the largest average among them as a float.
Example 1
nums [1,12,-5,-6,50,3]
k 4
returns 12.75
The stretch [12, -5, -6, 50] has sum 51, average 12.75.
Example 2
nums [5]
k 1
returns 5.0
One window, average 5.0.
Constraints
1 <= k <= len(nums) <= 50-50 <= nums[i] <= 50
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.