[Merge Two Sorted Arrays] Simple C++ Solution
\nclass Solution {\npublic:\n\n\t// at common point just compare the sum of two arrays calculated so far and assign maximum to the\n\t// our result variable and
```\nclass Solution {\npublic:\n\n\t// at common point just compare the sum of two arrays calculated so far and assign maximum to the\n\t// our result variable and make both sum values as 0 to start calculating again from that common point\n\n    int maxSum(vector<int>& arr1, vector<int>& arr2) {\n        \n        long i=0,j=0,sum1=0,sum2=0,result=0;\n        long m=arr1.size();\n        long n=arr2.size();\n    while(i<m && j<n)\n    {\n        if(arr1[i]==arr2[j])\n        {\n            result=result+max(sum1,sum2)+arr1[i];\n            i++;j++;\n            sum1=0;sum2=0;\n        }\n        else if(arr1[i]<arr2[j])\n        {\n            sum1=sum1+arr1[i];\n            i++;\n        }\n        else\n        {\n            sum2=sum2+arr2[j];\n            j++;\n        }\n    }\n    while(i<m)\n    {\n        sum1=sum1+arr1[i];\n        i++;\n    }\n    while(j<n)\n    {\n        sum2=sum2+arr2[j];\n        j++;\n    }\n    if(sum1!=0 || sum2!=0)\n    {\n        result=result+max(sum1,sum2);\n    }\n    return result%(1000000007);\n        \n    }\n};\n```
[]