Kadane's algorithm

what if all the inputs are negative
then the max array sum should be the minimum negative integer
how will we calculate this

Hey @bhattanurag426
U can make little bit changes in it to consider negatives also

Initalize maxsum as INT_MIN
And in loop before checking for sum<0 add statement to check max

ok sir i got it.

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.