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부터 시작하는 누적값중 최댓값 찾는 문제입니다.
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 1941. Check if All Characters Have Equal Number of Occurrences (0) | 2024.02.17 |
---|---|
백준 10798 세로읽기 (1) | 2024.02.15 |
leetcode 2784. Check if Array is Good (0) | 2024.02.14 |
leetcode 3024. Type of Triangle (0) | 2024.02.13 |
leetcode 3033. Modify the Matrix (1) | 2024.02.13 |
댓글