[C++] Beats 100%  Simple O(n) Time, O(1) Space
\tclass Solution {\n\tpublic:\n\t\tint maxSum(vector& nums1, vector& nums2) \n\t\t{\n        \n\t\tios_base::sync_with_stdio(false);\n        cin.tie(NULL);\n  
\tclass Solution {\n\tpublic:\n\t\tint maxSum(vector<int>& nums1, vector<int>& nums2) \n\t\t{\n        \n\t\tios_base::sync_with_stdio(false);\n        cin.tie(NULL);\n        cout.tie(NULL);\n        \n        int n1 = nums1.size(), n2 = nums2.size(), m = 1e9+7;\n        long long left = 0, right = 0;\n        \n        int i = n1-1, j = n2-1;\n        \n        while(i >= 0 || j >= 0)\n        {\n            if(i < 0)\n            {\n                right = nums2[j--] + right;\n                continue;\n            }\n            \n            if(j < 0)\n            {\n                left = nums1[i--] + left;\n                continue;\n            }\n            \n            if(nums1[i] < nums2[j])\n            {\n                right = nums2[j--] + right;\n            }\n            else if(nums1[i] > nums2[j])\n            {\n                left = nums1[i--] + left;\n            }\n            else\n            {\n                long long temp1 = left, temp2 = right;\n                left = nums1[i--]+max(temp1,temp2);\n                right = nums2[j--]+max(temp2,temp1);\n            }\n        }\n        return max(left,right)%m;\n    }};
[]