c++ sol and link to video for understanding the logic
link to nice video solution - https://youtu.be/JkodBYFv24I\n\nclass Solution {\npublic:\n    int maxSum(vector<int>& v1, vector<int>& v2) {\n        long long i
link to nice video solution - https://youtu.be/JkodBYFv24I\n```\nclass Solution {\npublic:\n    int maxSum(vector<int>& v1, vector<int>& v2) {\n        long long int sum1=0,sum2=0;\n        long long int ans=0;\n        int x=0; int y=0;\n        while(x<v1.size() and y<v2.size()){\n            while((x<v1.size() and y<v2.size()) and v1[x]!=v2[y]){\n                if(v1[x]<v2[y]){\n                    sum1+=v1[x];\n                    x++;\n                }else{\n                    sum2+=v2[y];\n                    y++;\n                }\n            }\n            if(x==v1.size() || y==v2.size()) break;\n            ans+=max(sum1,sum2)+v1[x];\n            sum1=0; sum2=0;\n            x++; y++;\n        }\n        while(x<v1.size()){\n            sum1+=v1[x];\n            x++;\n        }\n        while(y<v2.size()){\n            sum2+=v2[y];\n            y++;\n        }\n        ans+=max(sum1,sum2);\n        ans=ans% 1000000007;\n        return ans;\n    }\n};\n```\n
[]