Maximum circular sum

I’m not able to understand the problem with my code.It works fine for the first test case only.

Hello @armaanbhardwaj23 your method is producing wrong answer for all the test cases .
other than 1st only .
Because you have implemented the code for the given test case only.
actually there is one other method for producing the result .
you can simply implement this by doing like first find the kadane sum of the original array
and then find the sum of the orginal array and then multiply each element by -1 .
then also find the kadane sum of changed array .
then you have to do the final comparison .
if the sum of the orginal array and kadane sum of the changed array is greater than the kadane sum of the orginal array .
then your answer is the sum of the orginal array and kadane sum.
else your answer is the kadane sum of the orginal array .

I hope I’ve cleared your doubt …
Happy Learning !!

1 Like