n + 1 points. They start at point 0 at height 0.
You get an array changes of length n: changes[i] is how much the height changes going from point i to point i + 1 (a negative value means going down).
Return the height of the highest point on the trail, the starting point included.changes=[3, -1, 4, -10] → 6
The heights are 0, 3, 2, 6, −4. The highest is 6.
changes=[-2, -5, 3] → 0
The heights are 0, −2, −7, −4. The trail never climbs above the start, so the answer is 0.
changes=[3, -1, 4, -10]
6
Run checks the first 3 tests in your browser. Submit checks all 108 tests on the server, hidden ones included.