leetpycode/easy/find_the_highest_altitude.py

12 lines
No EOL
319 B
Python

# https://leetcode.com/problems/find-the-highest-altitude
from typing import List
class Solution:
def largestAltitude(self, gain: List[int]) -> int:
result = 0
current = 0
for altitude in gain:
current += altitude
result = max(current, result)
return result