DEV Community

Haripriya V
Haripriya V

Posted on

ASSIGNMENT 11

KADANES ALGORITHM

`class Solution:
def maxSubarraySum(self, arr):
max_sum = arr[0]
current_sum = arr[0]

    for i in range(1, len(arr)):
        current_sum = max(arr[i], current_sum + arr[i])
        max_sum = max(max_sum, current_sum)

    return max_sum`
Enter fullscreen mode Exit fullscreen mode

Top comments (0)