1
from itertools import accumulate5
def maxSum(self, nums1: List[int], nums2: List[int]) -> int:6
acc1 = list(accumulate(nums1, initial=0))7
acc2 = list(accumulate(nums2, initial=0))8
i, j = len(nums1) - 1, len(nums2) - 19
previ, prevj = len(nums1), len(nums2)11
while i >= 0 and j >= 0:12
while i >= 0 and j >= 0 and nums1[i] < nums2[j]:14
if i >= 0 and j >= 0 and nums1[i] == nums2[j]:15
prev_maxscore += max(acc1[previ] - acc1[i], acc2[prevj] - acc2[j])19
while i >= 0 and j >= 0 and nums2[j] < nums1[i]:21
if i >= 0 and j >= 0 and nums1[i] == nums2[j]:22
prev_maxscore += max(acc1[previ] - acc1[i], acc2[prevj] - acc2[j])26
prev_maxscore += max(acc1[previ] - acc1[0], acc2[prevj] - acc2[0])27
return prev_maxscore % (10**9 + 7)