```
public double findMaxAverage(int[] nums, int k) {
int anchor=nums[0];
double sum=nums[0];
for(int i=1;i<nums.length;i++)
{
if(k-i==0)
{
anchor=Math.max(nums[i],anchor+nums[i]);
sum=Math.max(sum,anchor);
}
}
return sum/k;
}
```