Skip to content

Commit

Permalink
kadane's algorithm added
Browse files Browse the repository at this point in the history
  • Loading branch information
mursalatul committed Jan 23, 2024
1 parent fb6cecd commit 744e359
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions UPDATE_DOC.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Files:
# special cases to restrict
# this folders will not be considered as regular folder to add in DOCUMENTATION.md
SPECIAL_FILES_TO_IGNORE = ["LICENSE", "venv", "virtual_env", "env",
"environment", "ADMIN", "CONTENT"]
"environment", "ADMIN", "CONTENT", "__pycache__"]

# this languages only will be accespted to commit
LENGUAGE_EXTENTION = [".cpp", ".c", ".py", ".java"]
Expand Down Expand Up @@ -178,7 +178,7 @@ def main():
# getting file data
ff = Files()
data = (ff.get_all_valid_folder_files_dict(cwd))
print(data)
# print(data)

# writing to Documentation.md
doc = CreateDocumentation()
Expand Down
2 changes: 1 addition & 1 deletion check.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from ADMIN.MAINTAIN.classes.Files import Files
from UPDATE_DOC import Files


def main():
Expand Down
24 changes: 24 additions & 0 deletions kadanes_algorithm/maxsum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <iostream>
#include <vector>
#include <limits.h>
using namespace std;

int maxsum(vector<int> v)
{
int max_sum = INT_MIN, temp_sum = 0;
for (int i = 0; i < (int)v.size(); i++)
{
temp_sum += v[i];
if (temp_sum > max_sum)
max_sum = temp_sum;
if (temp_sum < 0)
temp_sum = 0;
}
return max_sum;
}

int main()
{
vector<int> v = {-2, -1, 1, 4, 7, -1, 5, 0, 5};
cout << maxsum(v);
}

0 comments on commit 744e359

Please sign in to comment.