python 3 || two-pointers || O(m + n)/O(1)
```\nclass Solution:\n    def maxSum(self, nums1: List[int], nums2: List[int]) -> int:\n        i = j = score1 = score2 = maxScore = 0\n        m, n = len(nums1
```\nclass Solution:\n    def maxSum(self, nums1: List[int], nums2: List[int]) -> int:\n        i = j = score1 = score2 = maxScore = 0\n        m, n = len(nums1), len(nums2)\n        MOD = 10 ** 9 + 7\n        \n        while i < m and j < n:\n            if nums1[i] < nums2[j]:\n                score1 += nums1[i]\n                i += 1\n            elif nums1[i] > nums2[j]:\n                score2 += nums2[j]\n                j += 1\n            else:\n                maxScore += nums1[i] + max(score1, score2)\n                maxScore %= MOD\n                score1 = score2 = 0\n                i += 1\n                j += 1\n        \n        while i < m:\n            score1 += nums1[i]\n            i += 1\n        while j < n:\n            score2 += nums2[j]\n            j += 1\n        \n        maxScore += max(score1, score2)\n        return maxScore % MOD
['Two Pointers', 'Greedy', 'Python', 'Python3']