[C++] Greedy on the Sum and Count-0
Intuition\n Describe your first thoughts on how to solve this problem. \n- Greedy on the following things:\n  - sum1: the sum of nums1\n  - sum2: the sum of num
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- Greedy on the following things:\n  - `sum1`: the sum of `nums1`\n  - `sum2`: the sum of `nums2`\n  - `zero1`: the number of `0` in `nums1`\n  - `zero2`: the number of `0` in `nums2`\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- There are only 4 cases:\n  - `zero1 == 0` and `zero2 == 0`\n    - both `sum1` and `sum2` can not be changed\n  - `zero1 == 0` and `zero2 > 0`\n    - only the `sum2` can be increased to `[sum2 + zero2, INF)`\n  - `zero1 > 0` and `zero2 == 0`\n    - only the `sum1` can be increased to `[sum1 + zero1, INF)`\n  - `zero1 > 0` and `zero2 > 0`\n    - both `sum1` and `sum2` can be increased\n    - choose the minimum of the intersection between `[sum1 + zero1, INF)` and `[sum2 + zero2, INF)`\n\n# Complexity\n- Time complexity: $$O(n)$$\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```\nclass Solution {\npublic:\n    // time/space: O(n)/O(1)\n    long long minSum(vector<int>& nums1, vector<int>& nums2) {\n        long long sum1 = accumulate(nums1.begin(), nums1.end(), 0LL);\n        long long sum2 = accumulate(nums2.begin(), nums2.end(), 0LL);\n        int zero1 = count(nums1.begin(), nums1.end(), 0);\n        int zero2 = count(nums2.begin(), nums2.end(), 0);\n        \n        // both `sum1` and `sum2` can not be changed\n        if ((zero1 == 0) && (zero2 == 0)) {\n            if (sum1 == sum2) return sum1;\n            return -1;\n        }\n        \n        // only the `sum2` can be increased to `[sum2 + zero2, INF)`\n        if (zero1 == 0) {\n            if (sum1 < (sum2 + zero2)) return -1;\n            return sum1;\n        }\n        \n        // only the `sum1` can be increased to `[sum1 + zero1, INF)`\n        if (zero2 == 0) {\n            if ((sum1 + zero1) > sum2) return -1;\n            return sum2;\n        }\n        \n        // both `sum1` and `sum2` can be increased\n        // choose the minimum of the intersection between `[sum1 + zero1, INF)` and `[sum2 + zero2, INF)`\n        return max(sum1 + zero1, sum2 + zero2);\n    }\n};\n```
['Greedy', 'Counting', 'C++']