Maximum Cir sum

Hi Chirag!
The approach you have used in this question in not correct. Think about Kadane’s algorithm.
There can be 2 cases in this question:
When max sum is given without wrapping:
Example: 1,-2,10,11,-1,20,-50
here 10,11,-1,20 will give the max sum, simple case : here kadane’s algo will work fine

case 2: Wrapping:
Example: -1 100 -10 17 3 4 -2 -2
here max sum will be given by 17,3,4,-2,-2,-1,100
wrapping is there, as we are starting at 17 then going on till -2,-2 and then going at -1,100 (as its a circular array so we can start from any point), here simple Kadane’s algo won’t work.

I have commented the hint in this code: