# Maximum Average Subarray I (Leetcode 643)

Problem Link: <https://leetcode.com/problems/maximum-average-subarray-i/>

```python
class Solution:
    def findMaxAverage(self, nums: List[int], k: int) -> float:
        
        n=len(nums)
        i=0
        j=0
        avg=float('-inf')
        summ=0
        while(j<n):
            summ+=nums[j]
            
            if(j-i+1<k):
                j+=1
            
            elif(j-i+1==k):
                avg=max(avg,summ/k)
                
                summ-=nums[i]
                
                i+=1
                j+=1
        
        return avg
```
