✅✅ Solution || C++ 🔥🔥
Code
# Code
```cpp []
class Solution {
private:
    // gets curSum and newSum, and counts the 0s in the array
    // curSum is with the 0s, newSum is with the 0s replaced with 1s
    void getCurAndNewSum(vector<int>& nums, long long& curSum, long long& newSum, long long& z_cnt){
        for(int num : nums){
            if (num) {
                curSum += num;
                newSum += num;
            } else {
                newSum += 1;
                z_cnt += 1;
            }
        }
    }

public:
    long long minSum(vector<int>& nums1, vector<int>& nums2) {
        // curSum is with the 0s, newSum is with the 0s replaced with 1s
        long long curSum1 = 0, curSum2 = 0, z_cnt_1 = 0, z_cnt_2=0;
        long long newSum1 = curSum1, newSum2 = curSum2;
        getCurAndNewSum(nums1, curSum1, newSum1, z_cnt_1);
        getCurAndNewSum(nums2, curSum2, newSum2, z_cnt_2);

        
        if (!z_cnt_1){
            if (curSum1 < curSum2 || curSum1 < newSum2) return -1;
        }
        if (!z_cnt_2){
            if (curSum2 < curSum1 || curSum2 < newSum1) return -1;
        }
        long long result = max(newSum1, newSum2);
        return result;
    }
};
```
['C++']