Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- python sorted
- 릿코드 풀기
- 릿코드풀이
- python xor
- python zip_longest
- 파이썬 알고리즘
- 릿코드풀기
- 알고리즘풀이
- 릿코드 파이썬
- 상가수익률계산기
- leetcode풀기
- 파이썬알고리즘풀기
- leetcode풀이
- 파이썬 알고리즘 풀기
- 릿코드
- python Leetcode
- 잇츠디모
- leetcode 풀기
- 파이썬릿코드
- 파이썬릿코드풀기
- 파이썬알고리즘
- python priority queue
- 파이썬 프로그래머스
- 파이썬 릿코드
- LeetCode
- 알고리즘풀기
- python 알고리즘
- 코틀린기초
- python 릿코드
- binary search
Archives
- Today
- Total
소프트웨어에 대한 모든 것
LeetCode 풀기 - 1732. Find the Highest Altitude 본문
반응형
1732. Find the Highest Altitude
https://leetcode.com/problems/find-the-highest-altitude/
Find the Highest Altitude - LeetCode
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)
class Solution:
def largestAltitude(self, gain: List[int]) -> int:
# The biker starts his trip on point 0
altitudes = [0]
# the net gain in altitude between points i and i+1
[altitudes.append(altitudes[-1] + g) for g in gain]
# Return the highest altitude of a point.
return max(altitudes)
솔루션2)
accumulate() 함수를 사용하고 초기 값을 0으로 지정한다.
class Solution:
def largestAltitude(self, gain: List[int]) -> int:
return max(accumulate(gain, initial=0))
반응형
'알고리즘 > LeetCode' 카테고리의 다른 글
LeetCode 풀기 - 441. Arranging Coins (0) | 2021.11.09 |
---|---|
LeetCode 풀기 - 260. Single Number III (0) | 2021.11.09 |
LeetCode 풀기 - 797. All Paths From Source to Target (0) | 2021.11.08 |
LeetCode 풀기 - 1688. Count of Matches in Tournament (0) | 2021.11.08 |
LeetCode 풀기 - 1342. Number of Steps to Reduce a Number to Zero (0) | 2021.11.07 |
Comments