What is wrong with my code?


please help me fix it

Hi… i can see u have already submitted it successfully and gained full points

Yes, i used kadanes algo, this code desent work dont know why

image
u have to declare m globally.


I have corrected ur code. but this might give tle due to O(N^2)

In first test case, ans should be 10 but in ur code ans is 9

just a min… let me check


its working fine now… i suggest u to use kadanes only

the code is unable to clear any testcase and shows compile message as TLE

i said na this is O(N^2) approach and will give TLE… Use kadanes it is O(N) and will pass

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.