C++ | GREEDY
Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \nO(n)\n- Space complexity:\n Add your space complexity here, e.g. O(n) \nO(1)\n# Code
# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(1)$$\n# Code\n```\nclass Solution {\npublic:\n    long long minSum(vector<int>& nums1, vector<int>& nums2) {\n        long long cnt1 = 0, cnt2 = 0, sum1 = 0, sum2 = 0;\n        for (int i : nums1) {\n            cnt1 += (i == 0);\n            sum1 += i;\n        }\n        for (int i : nums2) {\n            cnt2 += (i == 0);\n            sum2 += i;\n        }\n        if (sum1 + cnt1 > sum2 + cnt2) {\n            if (!cnt2) return -1;\n            return sum1 + cnt1;\n        } else if (sum1 + cnt1 < sum2 + cnt2) {\n            if (!cnt1) return -1;\n            return sum2 + cnt2;\n        }\n        return sum1 + cnt1;\n    }\n};\n```\n**Please upvote if u like the solution :)**
['Greedy', 'C++']