What is the error in this code
I didn’t get ur code. But what i have done in this question is that:
- First calculate the maximum subarray sum using kadane’s algorithm.
- Now make all elements of the array of opposite sign.(if positive then make it negative,if negative then make it positive)
- Now again use kadane algo to find max subarray sum.
- Subtract the result came from above by total sum.
- ans is the maximum of ans in step 4 and step 1.
what do you want to explain in the 4 point
subtract the total sum with kadane sum in step 3