Hint - Kadanes - O(n)


#1

Understand the following code and try to solve yourself please.