title: Find Maximum Average Subarray Of K Length
signature: def findMaximumAverageSubarrayOfKLength(arr: List[Int], n: Int, k: Int) = {
source_py: def find_maximum_average_subarray_of_k_length(arr, n, k):
      if (k > n):
          return (- 1)
      csum = ([0] * n)
      csum[0] = arr[0]
      for i in range(1, n):
          csum[i] = (csum[(i - 1)] + arr[i])
      max_sum = csum[(k - 1)]
      max_end = (k - 1)
      for i in range(k, n):
          curr_sum = (csum[i] - csum[(i - k)])
          if (curr_sum > max_sum):
              max_sum = curr_sum
              max_end = i
      return ((max_end - k) + 1)
source_cpp: int find_maximum_average_subarray_of_k_length(vector<int> arr, int n, int k) {
    if ( k > n ) return - 1;
    int * csum = new int [ n ];
    csum [ 0 ] = arr [ 0 ];
    for ( int i = 1;
    i < n;
    i ++ ) csum [ i ] = csum [ i - 1 ] + arr [ i ];
    int max_sum = csum [ k - 1 ], max_end = k - 1;
    for ( int i = k;
    i < n;
    i ++ ) {
      int curr_sum = csum [ i ] - csum [ i - k ];
      if ( curr_sum > max_sum ) {
        max_sum = curr_sum;
        max_end = i;
      }
    }
    delete [ ] csum;
    return max_end - k + 1;
  }