[LeetCode][Python3] 53. Maximum Subarray
2018. 9. 21. 01:08 |
프로그래밍/LeetCode
Problem :
https://leetcode.com/problems/maximum-subarray/description/
My Solution :
class Solution:
def maxSubArray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
dp = nums[:]
for i in range(1, len(nums)):
if dp[i-1] > 0:
dp[i] += dp[i-1]
return max(dp)
Comment :
전형적인 동적 프로그래밍 문제
'프로그래밍 > LeetCode' 카테고리의 다른 글
[LeetCode][Python3] 100. Same Tree (0) | 2018.09.26 |
---|---|
[LeetCode][Python3] 70. Climbing Stairs (0) | 2018.09.26 |
[LeetCode][Python3] 3. Longest Substring Without Repeating Characters (0) | 2018.09.24 |
[LeetCode][Python3] 2. Add Two Numbers (0) | 2018.09.24 |
[LeetCode][Python3] 38. Count and Say (0) | 2018.09.21 |
[LeetCode][Python3] 665. Non-decreasing Array (0) | 2018.09.13 |
[LeetCode][Python3] 705. Design HashSet (0) | 2018.09.12 |
[LeetCode][Python3] 706. Design HashMap (0) | 2018.09.12 |
최근에 달린 댓글 최근에 달린 댓글