Shortest simplest JS solution (just 14 lines)
Intuition\nMinimum sum for each is replacing each 0 with a 1. So minimum = (count of zeroes in array + sum of array).\nIf either array has a single 0, we can ad
# Intuition\nMinimum sum for each is replacing each 0 with a 1. So minimum = (count of zeroes in array + sum of array).\nIf either array has a single 0, we can add any amount to it, thus we can make it up to match any other array. If one array is missing a zero, it can only match up to its own total sum, thus we return -1 if for either array (arrayA sum + arrayA zero count > arrayB sum AND arrayB zero count = 0).\n\n# Approach\nUse array reduce to calculate the sums and  total number of zeroes for each array. Return -1 if we cannot create a match. Return the largest possible minimum sum for both arrays.\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\n/**\n * @param {number[]} nums1\n * @param {number[]} nums2\n * @return {number}\n */\nvar minSum = function (nums1, nums2) {\n    const sum1 = nums1.reduce((a, b) => a + b);\n    const sum2 = nums2.reduce((a, b) => a + b);\n    const count1 = nums1.reduce((a, b) => b === 0 ? ++a : a, 0);\n    const count2 = nums2.reduce((a, b) => b === 0 ? ++a : a, 0);\n\n    if (sum1 + count1 > sum2 && count2 === 0) return -1;\n    if (sum2 + count2 > sum1 && count1 === 0) return -1;\n\n    return Math.max(sum1 + count1, sum2 + count2);\n};\n```
['JavaScript']