Solution to Leetcode 1749. Maximum Absolute Sum of Any Subarray

This problem is very classic. I find it helpful to see all the values in the array, as differences between values in a series, and to draw it on paper. Don’t try to find a complicated solution to this problem. You only need to remember a couple of things like the minimum and maximum sum you encountered for instance. Try to do it in one simple pass.

We apply a simple greedy method to find the maximum absolute sum of any subarray.