Alexa is Amazon's virtual AI assistant. It makes it easy to set up your Alexa-enabled devices, listen to music, get weather updates, and much more. The team is working on a new feature that evaluates the aggregate temperature changes for a period based on the changes in temperature of previous and upcoming days.
Taking the change in temperature data of n days, the aggregate temperature change evaluated on the ith day is the maximum of the sum of the changes in temperatures until the ith day, and the sum of the change in temperatures in the next (n-i) days, with the ith day temperature change included in both.
Given the temperature data of n days, find the maximum aggregate temperature change evaluated among all the days.
Example
tempChange = [6, -2, 5]
The aggregate temperature on each day is evaluated as: see image.
The maximum aggregate temperature change is max(9, 4, 9) = 9.
Function Description
Complete the function getMaxAggregateTemperatureChange.
getMaxAggregateTemperatureChange has the following parameter:
int tempChange[n]: the temperature change data of n days
Returns
long: the maximum aggregate temperature change
Constraints
Sample Case 0
Sample Input For Custom Testing
STDIN FUNCTION
----- --------
3 -> tempChange[] size n = 3
-1 -> tempChange = [-1, 2, 3]
2
3
Sample Output
5