Https://ide.codingblocks.com/s/126199

showing correct output on your ide but failing the testcases

share the link of your code

i hope you are using kadanes algo

shared already with you.

yes using kadanes algo

please help me out ,

sorry i didnt check the title of your doubt

no problem.please resolve now

see when you are checking csum<0 you are setting the values of csum to 0 and msum to 0
but you do not have to set msum to 0(csum being negative doesnt mean that msum will become negative)
so just remove the line msum=0(line no 34)

if the array starts with some negative number then according to you from my first if loop the msum will get initialized to the negative number.but we want to store 0 as per now . so to counter this i have initialized msum as 0 in 2nd loop

what you can do is initialize csum=arr[0] and msum=arr[0]…and start the for loop from i=1

for input arr={-2} output should be -2 only…because -2 is the maximum subarray sum possible