Maximum circular sum

output is always coming out to be 0.
link…

Hello @GreatCoderboy123

You have implemented the “kadane” function correctly but there are some errors in the “circular” function.

The circular function should be implmented like this.
First calculate the total sum of the array, Let it be “arrSum”.
Invert the signs of all the elements in the array.
Run kadane algorithm on this array to find the largest positive part in this new array (This part would be most negative in the original array as all the signs are inverted), Let it be “y”.
return “arrSum” + “y”; (Total sum of the array + Removing the most negative part)

The modified code

thank you …I understand it now…but it is giving wrong output for test case…what should be the output if all numbers in array are negative…should it be kadane function’s output only in that case without the condition of negative sum being zero?

Hello @GreatCoderboy123

The output should be zero if all the numbers in the array are negative.
Because in this case, one would NOT pick any element.