[Python] Very simple solution with explanation
py\nclass Solution:\n    def maxSum(self, nums1: List[int], nums2: List[int]) -> int:\n        ## RC ##\n        ## APPROACH : GREEDY ##\n        ## LOGIC ##\n 
```py\nclass Solution:\n    def maxSum(self, nums1: List[int], nums2: List[int]) -> int:\n        ## RC ##\n        ## APPROACH : GREEDY ##\n        ## LOGIC ##\n        ## 1. similar to merging 2 sorted arrays\n        ## 2. Maintain sum for each array\n        ## 3. when you find the same element in both arrays, only take maximum of sum1, sum2 and reset them\n        \n        p1, p2, sum1, sum2, result = 0, 0, 0, 0, 0\n        while(p1 < len(nums1) and p2 < len(nums2)):\n            if nums1[p1] == nums2[p2]:\n                result += max(sum1, sum2) + nums1[p1]\n                sum1, sum2 = 0, 0\n                p1, p2 = p1 + 1, p2 + 1\n            elif nums1[p1] < nums2[p2]:\n                sum1 += nums1[p1]\n                p1 += 1\n            else:\n                sum2 += nums2[p2]\n                p2 += 1\n\n        while(p1 < len(nums1)):\n            sum1 += nums1[p1]\n            p1 += 1\n\n        while(p2 < len(nums2)):\n            sum2 += nums2[p2]\n            p2 += 1\n\n        return (result + max(sum1 , sum2)) % (10**9 + 7)\n```\nPlease upvote if you like my solution
['Python', 'Python3']