CPP - Maximum Subarray Sum 3 (Kadane's Algo)

Do we take assumption here that the maximum subarray sum is greater than equal to 0? Since, if the maximum sum is negative, this algorithm is failing. Suuppose array = {-1,-2,-3}. Maximum sum = -3 but this algorithm reports 0. Please help.

Hello @nikunj19093,

Yes, the logic Sir is explaining in the video does not support negative sum as maximum sum.

You have to make some modifications in the code to support the negative sum.
Try to do it yourself first. Think about it.

If you still face any difficulty, refer the following code i have written:

Hope, this would help.
Give a like if you are satisfied.

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.