public double findMaxAverage(int[] nums, int k) {

double maxAverage = 0;

if (nums.length < k) {

return maxAverage;

} else {

for (int j = 0; j < k ; j++) {

maxAverage += nums[j];

}

double average = maxAverage;

for (int i = k; i < nums.length; i++) {

average += nums[i];

average -= nums[i-k];

maxAverage = Math.max(average, maxAverage);

}

}

return maxAverage/k;

}