标签:ret tps ++ int return solution tco double amp
class Solution {
public:
double findMaxAverage(vector<int>& nums, int k) {
double len=nums.size();
double sum_now=0;
double sum_max=0;
for(int i=0;i<k;i++){
sum_now+=nums[i];
}
sum_max=sum_now;
for(int i=k;i<len;i++){
sum_now=sum_now+nums[i]-nums[i-k];
sum_max=max(sum_max,sum_now);
}
return sum_max;
}
};
标签:ret tps ++ int return solution tco double amp
原文地址:https://www.cnblogs.com/zhmlzhml/p/14370776.html