Maximum Absolute Sum of Any Subarray LeetCode solution in Python

1
class Solution:
2
def maxAbsoluteSum(self, A):
3

4
ma, mi, res = 0, 0, 0
5
for a in A:
6
ma = max(0, ma + a)
7
mi = min(0, mi + a)
8
res = max(res, ma, -mi)
9
return res

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0