Amazon interview question

Sliding window like question (Kadane's algorithm)