Why wrong answer?

what’s wrong with my code

Hello @ankush.bhardwaj0,

Your code is giving wrong output for the testcases like:
example 1:
1
8
10 -3 -4 7 6 5 -4 -1
Expected Output:
23
Your Output:
37

example 2:
1
4
1 2 3 4
Expected Output:
10
Your Output:
16

BTW, the last lecture, Editorial - Maximum Circular Subarray Sum, of the section Arrays 1.0 (Problem Solving on 1D Arrays) covers this question with a more efficient way.

Your code’s complexity is O(n^2).
There, they have explained you to do this in O(n) time complexity.

Hope, this would help.
Let me know, if you still face any issue.

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.