100% Beats | Java | Readable
\n# Code\n\nclass Solution {\n    public long minSum(int[] nums1, int[] nums2) {\n        long sum1 = 0;\n        long sum2 = 0;\n        int zeroCnt1 = 0, zero
\n# Code\n```\nclass Solution {\n    public long minSum(int[] nums1, int[] nums2) {\n        long sum1 = 0;\n        long sum2 = 0;\n        int zeroCnt1 = 0, zeroCnt2 = 0;\n\n        for (int num : nums1) {\n            sum1 += num;\n            if (num == 0) {\n                zeroCnt1++;\n                sum1++;\n            }\n        }\n\n        for (int num : nums2) {\n            sum2 += num;\n            if (num == 0) {\n                zeroCnt2++;\n                sum2++;\n            }\n        }\n\n        if (sum1 == sum2) {\n            return sum1;\n        } else {\n            if (sum1 < sum2) {\n                if (zeroCnt1 > 0) {\n                    return sum2;\n                } else {\n                    return -1;\n                }\n            } else {\n                if (zeroCnt2 > 0) {\n                    return sum1;\n                } else {\n                    return -1;\n                }\n            }\n        }\n    }\n}\n\n```
['Java']