[Python 3]
\n def maxSum(self, nums1: List[int], nums2: List[int]) -> int:\n        s1, s2 = [0], [0]\n        cur = 0\n        for n in nums1:\n            cur += n\n    
```\n def maxSum(self, nums1: List[int], nums2: List[int]) -> int:\n        s1, s2 = [0], [0]\n        cur = 0\n        for n in nums1:\n            cur += n\n            s1.append(cur)\n        cur = 0\n        for n in nums2:\n            cur += n\n            s2.append(cur)\n        portal, i , j m, n = [], 0, 0, len(nums1), len(nums2)\n        while i < m and j < n:\n            if nums1[i] < nums2[j]:\n                i += 1\n            elif nums1[i] > nums2[j]:\n                j += 1\n            else:\n                portal.append([i, j])\n                i += 1\n                j += 1\n        if not portal:\n            return max(s1[-1], s2[-1])\n        l, idx, ans = len(portal), 0, max(s1[portal[idx][0]], s2[portal[idx][1]])\n        while idx < l - 1:\n            ans += max(s1[portal[idx + 1][0]] - s1[portal[idx][0]], s2[portal[idx + 1][1]] - s2[portal[idx][1]])\n            idx += 1\n        ans += max(s1[-1] - s1[portal[-1][0]], s2[-1] - s2[portal[-1][1]])\n        return ans % (10 ** 9 + 7)\n```
[]