Skip to content

Latest commit

 

History

History

KadaneAlgorithm

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Kadane's Algorithm

This algorithm is used to compute the largest contiguous subarray sum.

Consider the following example: 
a = {-2, -3, 4, -1, -2, 1, 5, -3}

Largest contiguous subarray sum is 7 and the required subarray is {4, -1, -2, 1, 5}

Time Complexity

O(n) where n is length of the array

Space Complexity

O(1) which means constant space