Kadane algo issue

this will not work if all the numbers are negative?

No, this algorithm wont work when all numbers in a array are negative, so for kadane’s algo to work, atleast one element needs to be positive…