解题思路

ZGBranch 发表于 2年前 · 关联问题 [算法课分治] 找到最大子序和

import ast class Solution(object):

def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ for i in range(1, len(nums)):#range使用方法:range(start,stop[,step]) nums[i]= nums[i] + max(nums[i-1], 0) return max(nums)

obj = ast.literal_eval(input()) use1 = Solution() print(use1.maxSubArray(obj))