2036. Maximum Alternating Subarray Sum
Содержание
class Solution:
def maximumAlternatingSubarraySum(self, nums: List[int]) -> int:
res = f = g = -inf
for x in nums:
f, g = max(g, 0) + x, f - x
res = max(res, f, g)
return res