MySolution

I tried to get the maximum sum and while searching for that obtaining its initial and final positions.

Thanking you in advance.

HERE is an very simple optimised one loop DP approach… Better than editorial approach…

I can help with your approach if you explain it…

thanks for this question… I liked solving it…

In my approach, i’m calculating the sum of the elements in array whenever my sum is less than any positive array element i reset the i.e sum=a[i] and set a new position (ipos=i). And for ending position whenever my sum is greater than max_sum ,I store that index as end position.

When i got these sum, ipos n epos.

I traverse that segment and tried find a negative number for removal.

And max-(negative number)=max+number.

Thanks buddy.