Return a Heap Array of Running Maximums
hardQuestion 719Write exactly this function:
int* runningMax(const int* values, int n);
It returns a NEW array of n ints in which element i is the largest value found in values[0] through values[i]. The function allocates that array and returns it; it must not print anything.
In main: read an integer n (at least 1), read n integers into a heap array you allocate with new int[n], call runningMax, print the result, and then delete[] BOTH arrays.
Print exactly two lines. For the input 5 then 3 1 7 4 9 the output is exactly what is shown in Expected Output.
Line 1 is the literal text Running max: followed by each element of the returned array, each one preceded by a single space. Line 2 is Final: followed by the last element of that array.
Free the memory you allocate - this question checks for memory leaks.
Write everything yourself, including main.
Expected output
Running max: 3 3 7 7 9 Final: 9
= newline. The output ends with a newline, so print one after the last line.
Your output
Run your code to see the output here...