1732. Find the Highest Altitude
class Solution:
def largestAltitude(self, gain: List[int]) -> int:
result = [0] * (len(gain) + 1)
for i in range(1, len(gain) + 1):
result[i] = gain[i-1] + result[i-1]
return max(result)
Pythonic한 코드는 다음과 같다.
class Solution:
def largestAltitude(self, gain: List[int]) -> int:
return max(accumulate(gain, initial = 0))