A bike rider is going on a ride. The road contains n + 1 points at different altitudes. The rider starts from point 0 at an altitude of 0.
Given an array of integers gain of length n, where gain[i] represents the net gain in altitude between points i and i + 1 for all (0 <= i < n), return the highest altitude of a point.
[-5, 1, 5, 0, -7]
1
[-5, -4, 1, 1, -6], where 1 is the highest altitude reached.[4, -3, 2, -1, -2]
4
[4, 1, 3, 2, 0], where 4 is the highest altitude reached.[2, 2, -3, -1, 2, 1, -5]
4
[2, 4, 1, 0, 2, 3, -2], where 4 is the highest altitude reached.Constraints:
n == gain.length1 <= n <= 100-100 <= gain[i] <= 100