Skip to content

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.

Easy#1732
LeetCode Problem

Find the Highest Altitude

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

Input
gain = [-5,1,5,0,-7]
Output
1

# Example 2

Input
gain = [-4,-3,-2,-1,4,3,2]
Output
0

Constraints

n == gain.length
1 <= n <= 100
-100 <= gain[i] <= 100

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.