Problem Solving/LeetCode
2023.06.19 Today's Challenge
fabichoi
2023. 6. 19. 23:45
https://leetcode.com/problems/find-the-highest-altitude/
Find the Highest Altitude - LeetCode
Can you solve this real interview question? Find the Highest Altitude - There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0. You are given an integ
leetcode.com
오랫만에 매우 쉬운 문제가 나왔음.
class Solution:
def largestAltitude(self, gain: List[int]) -> int:
h = 0
res = h
if len(gain) == 1:
return h if h > gain[0] else gain[0]
for g in gain:
h += g
res = max(res, h)
return res
반응형