본문 바로가기
python-algorithm

leetcode 1732. Find the Highest Altitude

by 무적김두칠 2024. 2. 15.

https://leetcode.com/problems/find-the-highest-altitude/description/

 

LeetCode - The World's Leading Online Programming Learning Platform

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

1
2
3
4
5
6
7
8
class Solution:
    def largestAltitude(self, gain: List[int]) -> int:
        answer = [0]
        for altitude in gain:
            answer.append(answer[-1+ altitude)
        
        return max(answer)
 
cs

0부터 시작하는 누적값중 최댓값 찾는 문제입니다.

반응형

댓글