Easy CPP solution
Complexity\n- Time complexity: O(n + m)\n\n- Space complexity: O(1)\n\n# Code\n\nclass Solution {\npublic:\n    long long minSum(vector<int>& nums1, vector<int>
# Complexity\n- Time complexity: $$O(n + m)$$\n\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n    long long minSum(vector<int>& nums1, vector<int>& nums2) {\n        long long nums1Sum = 0, nums2Sum = 0, nums1ZeroCount = 0, nums2ZeroCount = 0;\n        for(auto &i : nums1) {\n            nums1Sum += i;\n            if(i == 0) {\n                nums1ZeroCount++;\n            }\n        }\n        for(auto &i : nums2) {\n            nums2Sum += i;\n            if(i == 0) {\n                nums2ZeroCount++;\n            }\n        }\n        long long lowestNums1Sum = nums1Sum + nums1ZeroCount;\n        long long highestNums1Sum = nums1ZeroCount ? LLONG_MAX : nums1Sum;\n        long long lowestNums2Sum = nums2Sum + nums2ZeroCount;\n        long long highestNums2Sum = nums2ZeroCount ? LLONG_MAX : nums2Sum;\n        if(lowestNums1Sum > highestNums2Sum || highestNums1Sum < lowestNums2Sum) {\n            return -1;\n        }\n        return max(lowestNums1Sum, lowestNums2Sum);\n    }\n};\n```
['C++']