Java very simple modified merge sort
\nclass Solution {\n    public int maxSum(int[] nums1, int[] nums2) {\n        int i1 = 0;\n        int i2 = 0;\n        \n        long us = 0;\n        long ls
```\nclass Solution {\n    public int maxSum(int[] nums1, int[] nums2) {\n        int i1 = 0;\n        int i2 = 0;\n        \n        long us = 0;\n        long ls = 0;\n        \n        while ((i1 < nums1.length) && (i2 < nums2.length)) {\n            if (nums1[i1] == nums2[i2]) {\n                us = ls = (Math.max(us, ls) + nums1[i1]);\n                i1++;\n                i2++;\n            } else if (nums1[i1] < nums2[i2]) {\n                us += nums1[i1++];\n            } else {\n                ls += nums2[i2++];\n            }\n        }\n        \n        while (i1 < nums1.length) us += nums1[i1++];\n        while (i2 < nums2.length) ls += nums2[i2++];\n        \n        return ((int)(Math.max(us, ls) % 1000000007));\n    }\n}\n```
[]