# Maximum Circular Sum

How to solve this problem???

have you studied â€śkadaneâ€™s Algorithmâ€ť or not??
this question is solved using â€śkadaneâ€™s Algorithmâ€ť

if you donâ€™t know â€śkadaneâ€™s algorithmâ€ť first learn the algorithm
and if you know algorithm then seeâ€¦

Approach:

• Case A: If The elements that contribute to the maximum sum are not arranged in cyclic order.
Examples: {-8, 2, -1, 7}, max_sum=7
{-2, 6, -1, 7, -2} max_sum =(6+(-1)+7)=12
In this case, â€śkadane algorithmâ€ť solve our purpose.

• Case B: If The elements which contribute to the maximum sum are arranged in cyclic order. Examples: {10, -12, 11}, {8 -8 9 -9 10 -11 12}. In this case, we change cyclic to non-cyclic. Let us see how.

contributing elements(cyclic) sum = total sum - non-contributing elements(non-cyclic) sum,

so find out the sum of non-contributing elements and subtract this sum from the total sum. To find out the sum of non-contributions, run Kadaneâ€™s algorithm.

Reference Code is:

when i am dry running your code my opt2 is coming -1 and total is 11 then how the hell it is coming 22â€¦ i am not able to get your codeâ€¦i even wrote down on notebook

in your code at line no 28
`c2=c2+kadane(a,n);`
this is incorrect correct statement will be

### `c2=c2-kadane(a,n);`

now it should work fine

please explain me your code â€¦the problem i am facing in your code is when i am dry running your code my opt2 is coming -1 and total is 11 then how the hell it is coming 22â€¦ i am not able to get your codeâ€¦i even wrote down on notebook

well explained

but why isnâ€™t any test case is passing even after doing the changes you asked me to do it

are i watched your video and got the solution but why isnâ€™t test case getting solved??? itâ€™s not passing any test case