Counting Zeroes || Beats 100% || linear time || Easy
Approach\n1) Counting number of zeroes and sum of elemets for both array\n2) replacing all zeros with 1. \n Describe your approach to solving the problem. \n\n#
# Approach\n1) Counting number of zeroes and sum of elemets for both array\n2) replacing all zeros with 1. \n<!-- Describe your approach to solving the problem. -->\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    long long minSum(vector<int>& nums1, vector<int>& nums2) {\n        long long sum1 = 0;\n        long long sum2 = 0;\n        long long countZero1 = 0;\n        long long countZero2 = 0;\n        for(auto it : nums1){\n            sum1+=it;\n            if(it == 0){\n                countZero1++;\n            }\n        }\n        for(auto it : nums2){\n            sum2+=it;\n            if(it == 0){\n                countZero2++;\n            }\n        }\n        if((countZero1==0 && sum1 < sum2+countZero2)||(countZero2==0 && sum2 < sum1+countZero1)){\n            return -1;\n        }\n        return max(countZero1+sum1, countZero2+sum2);\n    }\n};\n```
['C++']