C++||easy and clean greedy approach.
```\nclass Solution {\npublic:\n    int maxSum(vector& nums1, vector& nums2) {\n        long long int ansa = 0;\n        long long int ansb = 0;\n        int i 
```\nclass Solution {\npublic:\n    int maxSum(vector<int>& nums1, vector<int>& nums2) {\n        long long int ansa = 0;\n        long long int ansb = 0;\n        int i =0;\n        int j =0;\n        while(i<nums1.size()&&j<nums2.size()){\n            if(nums1[i]<nums2[j]){\n                ansa+=nums1[i];\n                i++;\n            }\n            else if(nums1[i]>nums2[j]){\n                ansb+=nums2[j];\n                j++;\n            }\n            else {\n                long long int temp = max(ansa,ansb);\n                ansa=temp+nums1[i];\n                ansb=temp+nums2[j];\n                i++;\n                j++;\n            }\n        }\n        while(i<nums1.size()) {\n            ansa+=nums1[i];\n            i++;\n        }\n        while(j<nums2.size()){\n            ansb+=nums2[j];\n            j++;\n        }\n        return max(ansa,ansb)%1000000007;\n    }\n};\n
[]