1749. Maximum Absolute Sum of Any Subarray
On This Page
class Solution:
def maxAbsoluteSum(self, nums: List[int]) -> int:
f = g = 0
res = 0
for x in nums:
f = max(f, 0) + x
g = min(g, 0) + x
res = max(res, f, abs(g))
return res