class Solution:
def maxSubArray(self, nums: List[int]) -> int:
if len(nums)<2:
return nums[0]
result=[nums[0]]
for i in nums[1:]:
result.append(max(result[-1]+i,i))
return max(result)
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
if len(nums)<2:
return nums[0]
result=[nums[0]]
for i in nums[1:]:
result.append(max(result[-1]+i,i))
return max(result)
本文标题:2020-03-19 Day26 Leetcode: 53. M
本文链接:https://www.haomeiwen.com/subject/tvhkyhtx.html
网友评论