题目:
代码:
class Solution {
public:
double findMaxAverage(vector<int>& nums, int k) {
for(int i=1;i<nums.size();i++){
nums[i]=nums[i]+nums[i-1];
}
int m=nums[k-1];
for(int i=0;i+k<nums.size();i++){
m=max(m,nums[i+k]-nums[i]);
}
return (double)m/(double)k;
}
};