Nikzy7 / Algorithm-Snippets

Repo containing snippets of popular algorithms
17 stars 36 forks source link

Code of Kadane's Algorithm in C++ #57

Closed kartikeyaGUPTA45 closed 4 years ago

kartikeyaGUPTA45 commented 4 years ago

@Nikzy7 I add the code of Kadane Algorithm in C++ language Please check and merge it.

Kadane's Algorithm is used to find out the maximum subarray sum from an array of integers.

Algorithm:

Begin Function kadanes(int array[], int length): Initialize highestMax = 0 currentElementMax = 0 for i = 0 to length-1 currentElementMax = max(array[i],currentElementMax + array[i]) highestMax = max(highestMax, currentElementMax) return highestMax End

kartikeyaGUPTA45 commented 4 years ago

KARTIKEYA GUPTA

Nikzy7 commented 4 years ago

NP, I'll do it myself !

kartikeyaGUPTA45 commented 4 years ago

@Nikzy7, I added my name to contributors.md