# Max Sum Subarray of size K

Problem Link: <https://practice.geeksforgeeks.org/problems/max-sum-subarray-of-size-k5313/1>

```python
class Solution:
    def maximumSumSubarray (self,k,arr,n):
        # code here 
        i=0
        j=0
        ans=float('-inf')
        summ=0
        while(j<n):
            summ=summ+arr[j]
            
            if(j-i+1<k):
                j+=1
            
            elif(j-i+1==k):
                ans=max(ans,summ)
                
                summ=summ-arr[i]
                
                i+=1
                j+=1
        
        return ans
```
