simple two pointer update beats 99%
\npublic int maxSum(int[] nums1, int[] nums2) {\n        int i = 0, j = 0, mod = 1000000007;\n        long c1 = 0, c2 = 0;\n        while (i < nums1.length && j
```\npublic int maxSum(int[] nums1, int[] nums2) {\n        int i = 0, j = 0, mod = 1000000007;\n        long c1 = 0, c2 = 0;\n        while (i < nums1.length && j < nums2.length){\n            if (nums1[i]< nums2[j]){\n                c1+=nums1[i++];\n            }else if (nums1[i]> nums2[j]){\n                c2+=nums2[j++];\n            }else{\n                c1+=nums1[i++];\n                c2+=nums2[j++];\n                c1 = Math.max(c1,c2);\n                c2 = Math.max(c1,c2);\n            }\n        }\n        while (i < nums1.length){\n            c1 += nums1[i++];\n        }\n        while (j < nums2.length){\n            c2 += nums2[j++];\n        }\n        long res = Math.max(c1,c2)%mod;\n        return (int) res;\n    }\n```
[]