<p>You are given two arrays <code>nums1</code> and <code>nums2</code> consisting of positive integers.</p>

<p>You have to replace <strong>all</strong> the <code>0</code>&#39;s in both arrays with <strong>strictly</strong> positive integers such that the sum of elements of both arrays becomes <strong>equal</strong>.</p>

<p>Return <em>the <strong>minimum</strong> equal sum you can obtain, or </em><code>-1</code><em> if it is impossible</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums1 = [3,2,0,1,0], nums2 = [6,5,0]
<strong>Output:</strong> 12
<strong>Explanation:</strong> We can replace 0&#39;s in the following way:
- Replace the two 0&#39;s in nums1 with the values 2 and 4. The resulting array is nums1 = [3,2,2,1,4].
- Replace the 0 in nums2 with the value 1. The resulting array is nums2 = [6,5,1].
Both arrays have an equal sum of 12. It can be shown that it is the minimum sum we can obtain.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums1 = [2,0,2,0], nums2 = [1,4]
<strong>Output:</strong> -1
<strong>Explanation:</strong> It is impossible to make the sum of both arrays equal.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums1.length, nums2.length &lt;= 10<sup>5</sup></code></li>
	<li><code>0 &lt;= nums1[i], nums2[i] &lt;= 10<sup>6</sup></code></li>
</ul>

class Solution:
    def minSum(self, nums1: List[int], nums2: List[int]) -> int:
        # find sum of nums1, number of zeros
        # find sum of nums2, number of zeros

        # min_sum1 = sum of nums1 + 1*number of zeros -> 6+2 = 8, 2 zeros 6
        # min_sum2 = sum of nums2 + 1*number of zeros -=> 6+5+1 = 12, 1 zero 5
        
        # if both arrays have no zeros: compare sum of both
        # if one array no zeros: make sure min_sum < sum of array with no 0s, else -1

        # both arrays have at least 1 zero
        # return max(min_sum1, min_sum2)
        print(sum([0,16,28,12,10,15,25,24,6,0,0]))
        print(sum([20,15,19,5,6,29,25,8,12]))
        sum_1 = 0
        zeros_1 = 0
        sum_2 = 0
        zeros_2 = 0

        for num in nums1:
            sum_1 += num
            if num == 0:
                zeros_1 += 1
        for num in nums2:
            sum_2 += num
            if num == 0:
                zeros_2 += 1
        
        min_sum1 = sum_1 + zeros_1
        min_sum2 = sum_2 + zeros_2

        # comparing number of zeros
        if zeros_1 == 0 and zeros_2 == 0:
            if min_sum1==min_sum2:
                return min_sum1
            else:
                return -1
        elif zeros_1 == 0:
            if min_sum2 <= min_sum1:
                return min_sum1
            else: # array with 0s > array without 0s
                return -1 # not possible to increase sum of array with no 0s to matcjh other array
        elif zeros_2 == 0:
            if min_sum1 <= min_sum2:
                return min_sum2
            else: # array with 0s > array without 0s
                return -1 
        else: # both arrays have at least 1 zero
            return max(min_sum1, min_sum2)
850