corner logic handling - Java O(N) | O(1)
Intuition\n Describe your first thoughts on how to solve this problem. \nEasy logic, replace 0 with 1 so that we can find the bigger sum from the two arrays. Me
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nEasy logic, replace `0` with `1` so that we can find the bigger sum from the two arrays. Meanwhile we also need to make sure the smaller array has the enough zero to fill in the difference from bigger sum. In other words, if we don\'t have the zero slot or zero slots need to fill in a value bigger than Integer.MAX_VALUE, we should bail.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public long minSum(int[] nums1, int[] nums2) {\n        long sumBig = 0, sumSmall = 0;\n        int zeroBig = 0, zeroSmall = 0;\n        for (int val : nums1) {\n            if (val == 0) {\n                val++;\n                zeroBig++;\n            }\n            sumBig += val;\n        }\n        for (int val : nums2) {\n            if (val == 0) {\n                val++;\n                zeroSmall++;\n            }\n            sumSmall += val;\n        }\n        if (sumBig < sumSmall) {\n            sumBig = sumSmall + sumBig - (sumSmall = sumBig);\n            zeroBig = zeroSmall + zeroBig - (zeroSmall = zeroBig);\n        }\n        return (sumBig - sumSmall - zeroSmall) <= ((long)zeroSmall * Integer.MAX_VALUE) ? sumBig : -1;\n    }\n}\n```
['Java']