<p>You are given an integer array <code>nums</code> consisting of <code>n</code> elements, and an integer <code>k</code>.</p>

<p>Find a contiguous subarray whose <strong>length is equal to</strong> <code>k</code> that has the maximum average value and return <em>this value</em>. Any answer with a calculation error less than <code>10<sup>-5</sup></code> will be accepted.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,12,-5,-6,50,3], k = 4
<strong>Output:</strong> 12.75000
<strong>Explanation:</strong> Maximum average is (12 - 5 - 6 + 50) / 4 = 51 / 4 = 12.75
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [5], k = 1
<strong>Output:</strong> 5.00000
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>n == nums.length</code></li>
	<li><code>1 &lt;= k &lt;= n &lt;= 10<sup>5</sup></code></li>
	<li><code>-10<sup>4</sup> &lt;= nums[i] &lt;= 10<sup>4</sup></code></li>
</ul>

class Solution:
    def findMaxAverage(self, nums: List[int], k: int) -> float:
        maxAvg = 0
        for i in range(k):
            maxAvg += nums[i]
        currentAvg = maxAvg

        L = 0
        R = k - 1
        while R < len(nums) - 1:
            R += 1
            currentAvg -= nums[L]
            currentAvg += nums[R]

            if currentAvg > maxAvg:
                maxAvg = currentAvg

            L += 1
            

        return maxAvg / k
"""
maxAvg = -999999999
window size = k
L start at 0
R start at k - 1
L & R += 1 until window size

"""

28600