Simple C++
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    long long minSum(vector<int>& nums1, vector<int>& nums2) {\n        long long sum1 = 0, sum2 = 0;\n        long long zeroCount1 = 0, zeroCount2 = 0;\n        \n        // Calculate sum and zero counts for nums1\n        for (int x : nums1) {\n            if (x == 0) {\n                zeroCount1++;\n            } else {\n                sum1 += x;\n            }\n        }\n        \n        // Calculate sum and zero counts for nums2\n        for (int x : nums2) {\n            if (x == 0) {\n                zeroCount2++;\n            } else {\n                sum2 += x;\n            }\n        }\n        \n        // If both arrays have zeros, the sums are independent\n        if (zeroCount1 > 0 && zeroCount2 > 0) {\n            return max(sum1 + zeroCount1, sum2 + zeroCount2);\n        }\n        \n        // If nums1 has no zeros but nums2 does, return sum of nums1 or handle\n        if (zeroCount1 == 0 && zeroCount2 > 0) {\n            return (sum2 + zeroCount2 > sum1) ? -1 : sum1;\n        }\n        \n        // If nums2 has no zeros but nums1 does, return sum of nums2 or handle\n        if (zeroCount2 == 0 && zeroCount1 > 0) {\n            return (sum1 + zeroCount1 > sum2) ? -1 : sum2;\n        }\n        \n        // If neither array has zeros, return the sum of the array that has the smaller sum\n        if (zeroCount1 == 0 && zeroCount2 == 0) {\n            return sum1 == sum2 ? sum1 : -1;\n        }\n\n        return -1;\n    }\n};\n\n```
['C++']