double findMaxAverage(vector<int>& nums, int k) { double max = INT_MIN; int len = nums.size(); if (len <= 4) { int sum = 0; for (int i = 0; i < len; i++) { sum += nums[i]; } max = sum; } else { for (int i = 0; i <= len - k; i++) { int sum = 0; for (int j = i; j < i + k; j++) { sum += nums[j]; } if (max < sum) { max = sum; } } } double avg = max / k; return avg; }