Python Two pointers beats 97% time 95% space
O(M + N) time complexity, O(1) space complexity\n\n```\nclass Solution:\n    def maxSum(self, nums1: List[int], nums2: List[int]) -> int:\n        i, j, m , n =
O(M + N) time complexity, O(1) space complexity\n\n```\nclass Solution:\n    def maxSum(self, nums1: List[int], nums2: List[int]) -> int:\n        i, j, m , n = 0, 0, len(nums1), len(nums2)\n        curNums1Sum, curNums2Sum = 0, 0\n        \n        while i < m and j < n:\n            if nums1[i] < nums2[j]:\n                curNums1Sum += nums1[i]\n                i += 1\n            elif nums1[i] > nums2[j]:\n                curNums2Sum += nums2[j]\n                j += 1\n            else:\n                curNums1Sum =  curNums2Sum = max(curNums1Sum, curNums2Sum) + nums1[i]\n                i += 1\n                j += 1\n                \n        curNums1Sum += sum(nums1[i:])\n        curNums2Sum += sum(nums2[j:])\n            \n        return max(curNums1Sum, curNums2Sum) % (10**9 + 7)
['Two Pointers', 'Python']