53. Maximum Subarray
Description
Solutions
Kadane's Algorithm
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
current_sum = nums[0]
high_sum = current_sum
for i in range(1, len(nums)):
current_sum = max(nums[i], current_sum + nums[i])
high_sum = max(current_sum, high_sum)
return high_sumMy Solution
Last updated