C++ 2 pointer
```\nclass Solution {\npublic:\n    int maxSum(vector& nums1, vector& nums2) {\n        long long sum = 0;\n        int i=0, j=0;\n        while(oneStep(nums1, 
```\nclass Solution {\npublic:\n    int maxSum(vector<int>& nums1, vector<int>& nums2) {\n        long long sum = 0;\n        int i=0, j=0;\n        while(oneStep(nums1, nums2, i, j, sum));\n        return sum % (long long)(1e9+7);\n    }\n    \n    bool oneStep(vector<int>& nums1, vector<int>& nums2, int& i, int& j, long long& sum){\n        auto sum1 = sum, sum2 = sum;\n        while(i<nums1.size() && j<nums2.size()){\n            if(nums1[i] == nums2[j]){\n                sum = max(sum1, sum2) + nums1[i];\n                i++, j++;\n                return true;\n            }\n            else if(nums1[i] < nums2[j]) sum1 += nums1[i++];\n            else sum2 += nums2[j++];\n        }\n        while(i < nums1.size()) sum1 += nums1[i++];\n        while(j < nums2.size()) sum2 += nums2[j++];\n        sum = max(sum1, sum2);\n        return false;\n    }\n};
[]