i wrote the code for this question but it is not giving the desirable output. please somebody tell me where i am doing wrong??
Max sum subarray
@abhijeet.srivastava6499 sir i made the changes as you said. now it is giving the correct answer but when i submit the same code then it is not accepted there.
it shows -
Dang! You couldn’t score a perfect 100 because you failed one or more testcases. This means that your program didn’t account for all input cases (did you account for negative numbers, for example?).
this is the modified code -
please look into this once 
@pushkar24sharma,
That could be because your approach is of O(n^2). It can give TLE for larger n. There is an O(n) algorithm, called kadane’s algorithm, its simple yet tricky. You should try that.
@abhijeet.srivastava6499 okay thank u sir. i did this question by kadane’s algo only. i only had doubt that why was this code not accepted there. it might be bcoz of O(n 2) approach.