Greedy | Step-by-Step Procedural Logic | Easy to Understand | Python3
Intuition / Approach\nBecause we have to replace all zeros with at least one for each place, we know we can definitely achieve a common minimum by incrementing 
# Intuition / Approach\nBecause we have to replace all zeros with at least one for each place, we know we can definitely achieve a common minimum by incrementing up the sum from the sum with the lower minimum, which is equivalent to the maximum of the minimums; or, if they both have the same sum + number of zeros, use the common minimum.\n\nWe just have to consider the edge cases:\n\n1. There are no zeros, so the sums have to be strictly equal\n2. One of the sums has no zeros, so the other minimum has to be less than or equal to the sum without zeros\n3. Vice versa\n\nApologies for the verboseness, but this solution compromises aims to compromise beauty for truth.\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution:\n    def minSum(self, nums1: List[int], nums2: List[int]) -> int:\n        # num of zeros\n        z1, z2 = 0, 0\n        # sums\n        s1, s2 = 0, 0\n        for i in range(len(nums1)):\n            s1 += nums1[i]\n            if not nums1[i]: z1 += 1\n        for i in range(len(nums2)):\n            s2 += nums2[i]\n            if not nums2[i]: z2 += 1\n        # no zeros in either, only possible if sums strictly equal\n        if not z1 and not z2:\n            if s1 == s2: return s1\n            else: return -1\n        # calculate min poss sums after replacement\n        min1, min2 = s1 + z1, s2 + z2\n        # no zeros in 1, min sum of nums2 must be <= s1\n        if not z1 and z2:\n            if min2 <= s1: return s1\n            else: return -1\n        # no zeros in 2, min sum of nums1 must be <= s2\n        if z1 and not z2:\n            if min1 <= s2: return s2\n            else: return -1\n        # if zeros in both, return max of min sums\n        if z1 and z2:\n            return max(min1, min2)\n```
['Python3']