C++|| TC-O(N), SC-O(1)|| very easy code
\nclass Solution {\npublic:\n    int maxSum(vector<int>& nums1, vector<int>& nums2) {\n        int n=nums1.size(),m=nums2.size();\n        long long ans=0,mod=1
```\nclass Solution {\npublic:\n    int maxSum(vector<int>& nums1, vector<int>& nums2) {\n        int n=nums1.size(),m=nums2.size();\n        long long ans=0,mod=1e9+7;\n        int i=0,j=0;\n        long long sum1=0,sum2=0;\n        while(i<n && j<m)\n        {\n            if(nums1[i]==nums2[j])\n            {\n                sum1+=nums1[i],sum2+=nums2[j];\n                ans=(ans+max(sum1,sum2))%mod;\n                i++,j++;\n                sum1=0,sum2=0;\n            }\n            else if(nums1[i]<nums2[j])\n            {\n                sum1+=nums1[i];\n                i++;\n            }\n            else {\n                sum2+=nums2[j];\n                j++;\n            }\n        }\n        while(i<n)\n        {\n            sum1+=nums1[i++];\n        }\n        while(j<m) sum2+=nums2[j++];\n        ans=(ans+max(sum1,sum2))%mod;\n        return ans;\n    }\n};\n```
['Two Pointers']