Maximum circular sum

not able to understand the solution can u explain it to me

please refer to this article https://www.geeksforgeeks.org/maximum-contiguous-circular-sum it includes both code and explaination

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

i already read the article and its still not clear to me

where are you confused

The doubt was reopened. Is your doubt resolved?

i am not able to understand starting from case1 what is wrapping and uske baad ek bhi cheez nahi aayi samjh code kasie work kar raha hai

Maximum Circular Subarray Sum (Editorial) Refer this discussion. This may help.

bro i am not understanding the code

There is nothing extra or different in the code. You just have to perform Kadane twice. If you are aware with the Kadane’s algorithm, you may not face any difficulty with the code. Just follow the steps as i have mentioned in the above link.

only one thing that i am not understanding is why do we have to reverse the array?? and then add it to cummulative sum of the array

To check for the maximum subarray sum (in a circular manner) we invert the sign of elements in the array.
As you know that Kadane algo gives the maxm subarry sum…so if you invert the sign of each element of the array and then apply Kadane, the maxm subarray sum now obtained will actually be the minimum subarray sum for the original array.
Now if you subtract the minimum sub array sum from cumulative sum you get maximum subarray sum in circular fashion.
In the above mentioned link, i have explained this with an example.You can refer that.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.