If all the elements are negative

If all the elements of the array are negative, then this algorithm can not give the maximum sum. How to resolve it?

update ms = max(cs,ms) before checking if(cs < 0).
and initialize ms as ms = INT_MIN.

but it is not mentioned in the video !

i guess they are not considering when answer can be a negative value ( or maybe forgot to consider).

okk sir thank you for helping

1 Like

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.