Ctrl K

The Hiker's Highest Point

Easy
A hiker walks a mountain trail marked with n + 1 points. They start at point 0 at height 0. You get an array changes of length n: changes[i] is how much the height changes going from point i to point i + 1 (a negative value means going down). Return the height of the highest point on the trail, the starting point included.
Example 1
changes=[3, -1, 4, -10] → 6

The heights are 0, 3, 2, 6, −4. The highest is 6.

Example 2
changes=[-2, -5, 3] → 0

The heights are 0, −2, −7, −4. The trail never climbs above the start, so the answer is 0.

Constraints
  • 1 ≤ len(changes) ≤ 100
  • -100 ≤ changes[i] ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsBalance Point Index EasyThe Battery Must Not Run Dry EasyBalance After Each Day EasyTotals of Odd-Length Slices EasyThe Busiest Year Easy
loading Python…
Input
changes=[3, -1, 4, -10]
Expected
6

Run checks the first 3 tests in your browser. Submit checks all 108 tests on the server, hidden ones included.