Maximum circular subarray problem

could you please check and let me know that why all the test-cases are not getting passed

hello @mridulpant all test cases will only pass if you know about kadanes algorithm .
please wait i will go through your code and let younknow about the error .

sure, let me know with your finding

your code is producing the correct answer for everytest case but still it is not passing one test case i.e 0

please help me in correcting it

hey as i have told you that your code is producing the correct result fot every test case but still your code is not passing one test case .
please wait we are checking the test cases once again .

@mridulpant
Your code fails for the testcase
1
5
-5 3 4 -2 1

Expected Output :
7

Your Output :
6

Your algorithm is wrong as it only covers one case when you actually need to find outputs for two cases and take their maximum.
Slight modifications for required to get the correct output.

Your have covered one of the cases yourself. The other case is simply maximum subarray sum i.e. when the array is non-circular. Find the max sum for that separately using Kadane Algo only and take the max of two cases. That will be your final output.

thanks , got the solution

hey @mridulpantif you feel that your doubt is cleared please mark this doubt as resolved .
Happy Learning !!

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.

All my test cases are passing except the 0 test case. Please help.