C++ clean code ,beats 100% of the solutions🔥
Intuition\nBrute force\n\n# Approach\nobservation based\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npu
# Intuition\nBrute force\n\n# Approach\nobservation based\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    \n    long long minSum(vector<int>& nums1, vector<int>& nums2) {\n        \n        long long n=nums1.size(),m=nums2.size();\n        long long s1=0,s2=0,c1=0,c2=0;\n        for(int i=0;i<n;i++){\n            s1+=nums1[i];\n            if(nums1[i]==0) c1++;\n        }\n        for(int i=0;i<m;i++){\n            s2+=nums2[i];\n            if(nums2[i]==0) c2++;\n        }\n\n        if(c1==0 && c2==0){\n            if(s1!=s2) return -1;\n            else return s1;\n        }\n       else if(c1==0 && c2!=0){\n            if(s1<=s2) return -1;\n           else {\n               if(c2>s1-s2) return -1;\n               else return s1;\n           }\n        }\n        else if(c1!=0 && c2==0){\n            if(s2<=s1) return -1;\n           else {\n               if(c1>s2-s1) return -1;\n               else return s2;\n           }\n        }\n        else{\n             return max(s1+c1,s2+c2);\n        }\n        return -1;\n    }\n};\n```
['C++']