Python3 branching based solution beats 90%
Intuition\n Describe your first thoughts on how to solve this problem. \nThis problem can be solved in O(N) time and O(1) space.\n\nAs zeroes are replaced with 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis problem can be solved in O(N) time and O(1) space.\n\nAs zeroes are replaced with positive values. This means each zero will at minimum increase the sum of its array by 1. We define `minimumPossibleSumArray = sum(array) + array.count(0)`\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\nCompute the sum of each array and the number of zeroes in each array. We have to consider the following cases:\n\n1. Sums of arrays are equal.\na. If both arrays have no zeroes, we return the sum of either array.\nb. If both arrays have at least one zero, we return the maximum of the minimum possible sums for both arrays.\nc. Otherwise, one array has a zero and the other does not. In this case, reconciling the sums is not possible. Return -1\n2. Sums of arrays are not equal.\na. If both arrays have no zeroes, we cannot make the sums equal. Return -1.\nb. If both arrays have at least one zero, we return the max of the minPossibleSums of each array. Note that this case is identical to 1b.\nc. If one array has no zeroes, we check that the minPossibleSum of the other array that does have a zero is <= the sum of the array that does not have a zero. In this case, we will return the sum of the array that does not have a zero.\nd. Return -1\n\nThe code below expresses these conditions directly. It is possible to refactor\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N) to compute sums and counts of zeroes\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1) since we just have a bunch of if conditions to run through.\n# Code\n```\nclass Solution:\n    def minSum(self, nums1: List[int], nums2: List[int]) -> int:\n        sum1 = sum(nums1)\n        zeroes1 = nums1.count(0)\n        sum2 = sum(nums2)\n        zeroes2 = nums2.count(0)\n        difference = abs(sum1 - sum2)\n        # cases\n        if difference == 0:\n            if zeroes1 == 0 and zeroes2 == 0:\n                return sum1\n            if zeroes1 > 0 and zeroes2 > 0:\n                return sum1 + max(zeroes1, zeroes2)\n            # one array has a zero and the other array does not have a zero\n            return -1\n        else:\n            minPossibleSumArray1 = sum1 + zeroes1\n            minPossibleSumArray2 = sum2 + zeroes2\n            if zeroes1 == 0 and zeroes2 == 0:\n                # cannot reconcile sum\n                return -1\n            if zeroes1 > 0 and zeroes2 > 0:\n                # the array with the smaller value has at least one zero\n                return max(minPossibleSumArray1, minPossibleSumArray2)\n            if zeroes1 == 0:\n                # array 2 does not have a zero. See if array1\'s minimum possible sum is <= that of array2\n                if minPossibleSumArray2 <= sum1:\n                    return sum1\n                return -1\n            if zeroes2 == 0:\n                # array 2 does not have a zero. See if array1\'s minimum possible sum is <= that of array2\n                if minPossibleSumArray1 <= sum2:\n                    return sum2\n                return -1\n            \n\n\n\n```\nIf we merge the conditions where both arrays have at least one zero, we can reduce the branches.\n```\nclass Solution:\n    def minSum(self, nums1: List[int], nums2: List[int]) -> int:\n        sum1 = sum(nums1)\n        zeroes1 = nums1.count(0)\n        sum2 = sum(nums2)\n        zeroes2 = nums2.count(0)\n        minPossibleSumArray1 = sum1 + zeroes1\n        minPossibleSumArray2 = sum2 + zeroes2\n        if zeroes1 > 0 and zeroes2 > 0:\n            return max(minPossibleSumArray1, minPossibleSumArray2)\n        if abs(sum1 - sum2) == 0:\n            # sums are already equal\n            if zeroes1 == 0 and zeroes2 == 0:\n                return sum1\n            # one array has a zero and the other array does not have a zero\n            return -1\n        else:\n            # cannot reconcile the difference\n            if zeroes1 == 0 and zeroes2 == 0:\n                return -1\n            if zeroes1 == 0:\n                # array 2 does not have a zero. See if array2\'s minimum possible sum is <= that of array1\n                if minPossibleSumArray2 <= sum1:\n                    return sum1\n                return -1\n            if zeroes2 == 0:\n                # array 2 does not have a zero. See if array1\'s minimum possible sum is <= that of array2\n                if minPossibleSumArray1 <= sum2:\n                    return sum2\n                return -1\n```
['Python3']