5th digit after decimal actual output is not same as the 5th digit after decimal of the expected output.
output: 558.29498 expected: 558.29496
double findMaxAverage(int* nums, int numsSize, int k){
float maxSum = -2147483648;
float currentSum = 0;
for(int i=0; i < numsSize; i++){
currentSum += nums[i];
if(i >= k - 1){
if(currentSum > maxSum) maxSum = currentSum;
currentSum -= nums[i - (k - 1)];
}
}
return maxSum/k;
}
I tried doing this-
return (double)maxSum/k;
Please help me out with this.