C++ two pointers solution linear time complexity
\nclass Solution {\npublic:\n    int maxSum(vector<int>& nums1, vector<int>& nums2) {\n        int i=0,j=0,n=nums1.size(),m=nums2.size();\n        long long int
```\nclass Solution {\npublic:\n    int maxSum(vector<int>& nums1, vector<int>& nums2) {\n        int i=0,j=0,n=nums1.size(),m=nums2.size();\n        long long int n1=0,n2=0,mod=1000000007,ans=0;\n        while(i<n || j<m){\n            if(i<n && (j==m || nums1[i]<nums2[j]))n1+=nums1[i++];\n            else if(j<m && (i==n || nums1[i]>nums2[j]))n2+=nums2[j++];\n            else{\n                ans+=max(n1,n2)+nums1[i];\n                n1=0;n2=0;\n                i++;j++;\n            }\n        }\n        return (max(n1,n2)+ans)%mod;\n    }\n};\n```
['C++']