Java straightforward loop only
\nclass Solution {\n     public long minSum(int[] nums1, int[] nums2) {\n        int c1 = 0, c2 = 0;\n        long s1 = 0, s2 = 0;\n        for (int num : nums1
```\nclass Solution {\n     public long minSum(int[] nums1, int[] nums2) {\n        int c1 = 0, c2 = 0;\n        long s1 = 0, s2 = 0;\n        for (int num : nums1) {\n            c1 += num == 0 ? 1 : 0;\n            s1 += num;\n        }\n        for (int num : nums2) {\n            c2 += num == 0 ? 1 : 0;\n            s2 += num;\n        }\n        return ((c1 == 0 && s1 - c2 < s2) || (c2 == 0 && s2 - c1 < s1)) ? -1 : Math.max(s1 + c1, s2 + c2);\n    }\n}\n```
['Java']