Trains the technique from
LeetCode 1749Maximum Absolute Sum of Any SubarrayThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A ledger of adjustments reads adjustments. A stretch is any run of neighbouring entries, and the empty stretch counts as one, with a total of nothing.
Return the largest size any stretch's total reaches, where size ignores whether the total came out above or below nothing.
Example 1
The whole ledger totals six, and no shorter stretch swings further in either direction.
Example 2
Every entry pulls downward, so the whole ledger's total of minus six is the furthest swing and its size is six.
Example 3
Either of the two rises on its own swings ten thousand. Taking more entries only cancels part of the swing away.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def max_absolute_sum(adjustments: list[int]) -> int:public int maxAbsoluteSum(int[] adjustments)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.