 # 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