92 ms, faster than 90.34% CPP SOLUTION - TIME - O(m+n) , SPACE - O(1)  --- TWO POINTERS
\nclass Solution {\npublic:\n    int maxSum(vector<int>& a, vector<int>& b) {\n        int mod=1e9+7;\n        int m=a.size();\n        int n=b.size();\n       
```\nclass Solution {\npublic:\n    int maxSum(vector<int>& a, vector<int>& b) {\n        int mod=1e9+7;\n        int m=a.size();\n        int n=b.size();\n        int i=0,j=0;\n        long long int sum1=0,sum2=0,totsum=0;\n        while(i<m && j<n)\n        {\n            if(a[i]<b[j])\n            {\n                sum1+=a[i];\n                i++;\n            }\n            else if(a[i]>b[j])\n            {\n                sum2+=b[j];\n                j++;\n            }\n            else \n            {\n                totsum+=max(sum1,sum2)+a[i];\n                i++;j++;\n                sum1=sum2=0;\n            }\n        }\n        while(i<m)\n        {\n            sum1+=a[i];\n            i++;\n        }\n        while(j<n)\n        {\n            sum2+=b[j];\n            j++;\n        }\n        totsum+=max(sum1,sum2);\n        totsum = totsum%mod;\n        return (int)totsum;\n    }\n};\n```\n\nPLEASE UPVOTE IF IT HELPS!
[]