Easy C++ Greedy Solution
Complexity
Time complexity: O(n1+n2), where n1 and n2 is the size of num1 and num2 respectively

Space complexity: O(1)
Code
# Complexity\n- Time complexity: $$O(n1 + n2)$$, where n1 and n2 is the size of num1 and num2 respectively\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\n#define ll long long\nclass Solution {\npublic:\n    long long minSum(vector<int>& nums1, vector<int>& nums2) {\n        ll sum1 = 0, sum2 = 0, zero1 = 0, zero2 = 0;\n        for(auto &i : nums1) {\n            sum1 += i * 1LL;\n            if(i == 0) {\n                zero1++;\n            }\n        }\n        for(auto &i : nums2) {\n            sum2 += i * 1LL;\n            if(i == 0) {\n                zero2++;\n            }\n        }\n        if(zero1 == 0 && zero2 == 0) {\n            return (sum1 == sum2) ? sum1 : -1;\n        } else if(zero1 != 0 && zero2 == 0) {\n            return (sum1 + zero1 > sum2) ? -1 : sum2;\n        } else if(zero1 == 0 && zero2 != 0) {\n            return (sum1 < sum2 + zero2) ? -1 : sum1;\n        } else {\n            return max(sum1 + zero1, sum2 + zero2);\n        }\n    }\n};\n\n// Time complexity: O(n1 + n2)\n// Space complexity: O(1)\n```
['C++']