문제
https://leetcode.com/problems/maximum-subarray/
Maximum Subarray - 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 maxSubArray(self, nums: List[int]) -> int:
for i in range(1, len(nums)):
nums[i] += nums[i-1] if nums[i-1]>0 else 0
return max(nums)
'⏳ 알고리즘 > python 알고리즘 문제 풀이' 카테고리의 다른 글
프로그래머스 - LV2. 방문 길이 (0) | 2022.10.13 |
---|---|
프로그래머스 - LV2. 주차 요금 계산 (0) | 2022.10.11 |
리트코드 - 509. Fibonacci Number (0) | 2022.04.27 |
프로그래머스 - LV3. 단어 변환 (0) | 2022.03.25 |
프로그래머스 - LV3. 네트워크 (0) | 2022.03.25 |