반응형
leetcode.com/problems/maximum-subarray/
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
maximum= -sys.maxsize
sum=0
for num in nums:
sum+=num
maximum = max(maximum, sum)
if sum < 0 and num <0:
sum = 0
return maximum
댓글