Easy Solution with linear time complexity
\n\n# Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \nO(N+M) where N and M are size of nums1 and nums2 respectively\n\n- Space compl
\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N+M) where N and M are size of nums1 and nums2 respectively\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    long long minSum(vector<int>& nums1, vector<int>& nums2) {\n        int znum1=0;\n        int znum2=0;\n        int n=nums1.size();\n        int m=nums2.size();\n        long long sum1=0;\n        long long sum2=0;\n        for(int i=0;i<n;i++){\n            sum1+=nums1[i];\n            if(nums1[i]==0){\n                znum1+=1;\n            }\n        }\n        for(int i=0;i<m;i++){\n            sum2+=nums2[i];\n            if(nums2[i]==0){\n                znum2+=1;\n            }\n        }\n        long long minsum2=sum2+znum2;\n        long long minsum1=sum1+znum1;\n        if(minsum2<minsum1 && znum2==0){\n            return -1;\n        }\n        if(minsum1<minsum2 && znum1==0){\n            return -1;\n        }\n        return max(minsum2,minsum1);\n    }\n};\n```
['C++']