Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Conversation

ivaibhavjindal
Copy link

Closes #100

for(int i = 0; i < size; i++)
{
//Iterate over Array adding each element to current max
currentMax = currentMax + arr[i];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong declaration of variable


//finalMax updated when less than currentMax
if(finalMax < currentMax)
finalMax = currentMax;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same. This type of method is used in functions

@@ -0,0 +1,46 @@
//MAXIMUM SUM OF SUBARRAY(CONTIGUOUS SUBSEQUENCE) KADANE'S ALGO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sample input output

@Bhavnaharitsa
Copy link
Member

The algorithm doesn't run properly in the first place
image
See this!

@ivaibhavjindal
Copy link
Author

I've added the Sample input/output and done the snake casing of variable names and camel casing of function name.
Regarding the working of algorithm, Can I know which compiler are you using because I've double checked the code and ran with g++ on my Computer and many different Online Compilers and the code works fine on each.
Codechef
OnlineGDB
CodingGround
g++

@Bhavnaharitsa Bhavnaharitsa merged commit 1d8fb54 into NJACKWinterOfCode:master Dec 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Kadane Algo

2 participants