Skip to content

Added an Algorithm for max-continous sub-array #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Kadane/kadane.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sys
def maxSubArraySum(a, size):
max_so_far = -sys.maxsize - 1
max_ending_here = 0

for i in range(0, size):
max_ending_here = max_ending_here + a[i]
if (max_so_far < max_ending_here):
max_so_far = max_ending_here

if max_ending_here < 0:
max_ending_here = 0
return max_so_far


# Driver function to check the above function
a = [-1, 0, 4, 2, -7, 1, 2, -3]
print("Maximum contiguous sum is", maxSubArraySum(a, len(a)))
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ After you've added code, just come back to readme and add your name under contri

[Milind Kumar](https://github.com/Graviton5)

[Ayan Banerjee](https://github.com/Ayan1089)

[Your name here](Your GitHub/Linkedin URL here)

## Final words
Expand Down