def maximumSubarray(nums):
localMax = globalMax = nums[0]
for ind, num in enumerate(nums[1:]):
localMax = max(num, num + localMax)
globalMax = max(localMax, globalMax)
return globalMax
nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
print('Maximum sum subarray ->' ,maximumSubarray(nums))
# OUTPUT: Maximum sum subarray -> 6
Really insightful! Thanks for breaking this down.
ReplyDeleteAdobe Photoshop Download
SuperAntiSpyWare Pro
PC Helpsoft Driver"