Skip to content

#1732 - Find the Highest Altitude

EasyPrefix Sum
Open on LeetCode

A biker starts a trip at altitude 0 and goes through n + 1 points. You are given an integer array gain of length n, where gain[i] is the net gain in altitude between points i and i + 1. Return the highest altitude reached.

InputOutput
gain = [-5,1,5,0,-7]1
gain = [-4,-3,-2,-1,4,3,2]0

Released under the MIT License.