All elements are negative

What if all the elements in the array are negative.We will get a max sum of 0 which will be a wrong answer.

Hi @TusHar-AroRa-2294450460870717

you can take a flag and set it whenever there isn’t any positive number. Then just output the maximum element of the array.

Hope it Helps.

1 Like