
[LeetCode] 1732. Find the Highest Altitude
·
코딩테스트/Python
🔗 Problem Linkhttps://leetcode.com/problems/find-the-highest-altitude/description/❔Thinking현재의 높이 0에서 주어지는 높이와의 차이를 순차적으로 계산하고(= net gain altitude) 업데이트한다.모든 net gain altitude 가운데에 가장 큰 값을 반환한다.💻Solutiondef largestAltitude(self, gain: List[int]) -> int: net_gain = [0] for h in gain: net_gain.append(net_gain[-1] + h) return max(net_gain)🗝️keypoint리스트 선언의 필요 없이, 두개의 변수를 통해 max 값..