Practice Find the Highest Altitude
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0. 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 for all (0 <= i < n). Return the highest altitude of a point.
Source: Find the Highest Altitude on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
gain = [-5,1,5,0,-7]
1
# Example 2
gain = [-4,-3,-2,-1,4,3,2]
0
Constraints
Related LeetCode Problems
Practice more problems similar to Find the Highest Altitude.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.