LeetCode|LeetCode 53. Maximum Subarray 时间复杂度(O(n))

class Solution: def maxSubArray(self, nums: [int]) -> int: res = nums[0] res_max = res for num in nums[1:]: res = num if res < 0 else res + num res_max = max(res_max, res) return res_max

【LeetCode|LeetCode 53. Maximum Subarray 时间复杂度(O(n))】

    推荐阅读