negetive valued array is giving zero ans in my output for this code.
what condition is to be applied?
Kadens algorithm for max subarray
When all array elements are negative the Kadane’s algo will not give the correct output. In such a case the output is simply the least negative number. So you can check the array if all array elements are -ve, if it is so then the answer will be the maximum among all numbers.
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.