title: Temple Offerings
signature: function templeOfferings($n, $templeheight) {
source_py: def temple_offerings(n, templeHeight):
      sum = 0
      for i in range(n):
          left = 0
          right = 0
          for j in range((i - 1), (- 1), (- 1)):
              if (templeHeight[j] < templeHeight[(j + 1)]):
                  left += 1
              else:
                  break
          for j in range((i + 1), n):
              if (templeHeight[j] < templeHeight[(j - 1)]):
                  right += 1
              else:
                  break
          sum += (max(right, left) + 1)
      return sum
source_cpp: int temple_offerings(int n, vector<int> templeHeight) {
    int sum = 0;
    for ( int i = 0;
    i < n;
    ++ i ) {
      int left = 0, right = 0;
      for ( int j = i - 1;
      j >= 0;
      -- j ) {
        if ( templeHeight [ j ] < templeHeight [ j + 1 ] ) ++ left;
        else break;
      }
      for ( int j = i + 1;
      j < n;
      ++ j ) {
        if ( templeHeight [ j ] < templeHeight [ j - 1 ] ) ++ right;
        else break;
      }
      sum += max ( right, left ) + 1;
    }
    return sum;
  }