Amazon Interview Question

Maximal Subarray(It is a standard question)