sir if i insert all negative number then it gives wrong answer so it is not useful for negative elements of the array ?
Negative element test case
this code can be altered just a little to make it compatible with arrays of all negative numbers. you just have to compare max_ending_here with max_so_far before you compare max_ending_here with zero.
Please look at this code for implementation details:
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.