logo
Problems

Maximum Subarray Difference

Problem

Given an array with integers. Find two non-overlapping subarrays A and B, which |SUM(A) - SUM(B)| is the largest. Return the largest difference.

Note

The subarray should contain at least one number

Example

For [1, 2, -3, 1], return 6.

Online Judge