Find the Highest Altitude Problem

Find the Highest Altitude Problem — ExecCode Easy DSA Practice

Solve the Find the Highest Altitude problem on ExecCode. Free online easy DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

A biker starts at altitude 0; gain[i] is the net elevation change between point i and point i+1. Return the highest altitude reached anywhere during the trip.

Examples

Input gain = [-5, 1, 5, 0, -7, 2]; Output 1. Input gain = [-4, -3, -2, -1, 4, 3, 2]; Output 0. Input gain = [1, 2, 3, -6, 4]; Output 6

Constraints

1 ≤ gain.length ≤ 100 -100 ≤ gain[i] ≤ 100

Practice Find the Highest Altitude free on ExecCode. Browse DSA problems, topic map, and placement guides.