Maximum Subarray Difference

O(n) time and O(n) space.