Highest Route Point

A biker starts at altitude 0, and each segment of the route changes the altitude up or down. Given a list gain, where gain[i] is the altitude change on the next segment, calculate the altitude after each segment. Return the highest altitude reached during the route.

Примеры

Ввод
[-5, 1, 5, 0, -7]
Вывод
1
Ввод
[-4, -3, -2, -1, 4, 3, 2]
Вывод
0
Ввод
[1, 2, 3]
Вывод
6

Нужно реализовать

def largest_altitude(gain: list[int]) -> int:

Теги

arraymath
PostgreSQLv16

Siia ilmub koodi käivituse tulemus

Visible tests
1
Input
[-5,1,5,0,-7]
Expected1
2
Input
[-4,-3,-2,-1,4,3,2]
Expected0
3
Input
[1,2,3]
Expected6
4
Input
[]
Expected0
5
Input
[44,32,-9,52,23,-39,-55,-30,-20,4]
Expected142
6
Input
[1,2,3,1,2]
Expected9
Focus radio
Paused · SomaFM · Fluid