[Python3] Greedy O(M+N), O(1)Space
Get the max value if two pointer are pointing the same element\n\nclass Solution:\n    def maxSum(self, nums1: List[int], nums2: List[int]) -> int:\n        mod
Get the max value if two pointer are pointing the same element\n```\nclass Solution:\n    def maxSum(self, nums1: List[int], nums2: List[int]) -> int:\n        mod=10**9+7\n        n1=n2=0\n        while nums1 and nums2:\n            if nums1[-1]==nums2[-1]:\n                n1+=nums1.pop()\n                n2+=nums2.pop()\n                n1=n2=max(n1,n2)\n            elif nums1[-1]>nums2[-1]:\n                n1+=nums1.pop()\n            else:\n                n2+=nums2.pop()\n        if nums1:\n            n1+=sum(nums1)\n        if nums2:\n            n2+=sum(nums2)\n        return max(n1,n2)%mod\n```
[]