Get Max Aggregate Temperature Change
Learn this problemProblem statement
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 change 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.
Function
getMaxAggregateTemperatureChange(tempChange: int[]) → long
Complete the function getMaxAggregateTemperatureChange in the editor.
getMaxAggregateTemperatureChange has the following parameter:
int tempChange[n]: the temperature change data ofndays
Returns
long: the maximum aggregate temperature change
Examples
Example 1
tempChange = [6, -2, 5]return = 9
Example 2
tempChange = [-1, 2, 3]return = 5Constraints
1 <= n <= 105-109 <= tempChange[i] <= 109 where, 1 <= i <= nMore Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026