Equal sum of two array
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\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```java []\nclass Solution {\n  public long minSum(int[] nums1, int[] nums2) {\n    long[] sum = new long[2];\n    int[] zero = new int[2];\n    for (int num : nums1) {\n      if (num == 0) {\n        zero[0]++;\n      }\n      sum[0] += num;\n    }\n\n    for (int num : nums2) {\n      if (num == 0) {\n        zero[1]++;\n      }\n      sum[1] += num;\n    }\n\n    // both have zero, replace all zero with one in one array\n    if (zero[0] > 0 && zero[1] > 0) {\n      return Math.max(sum[0] + zero[0], sum[1] + zero[1]);\n    }\n\n    // one of array has zero\n    if (zero[0] > 0 && zero[1] == 0) {\n      if (sum[0] < sum[1] && sum[0] + zero[0] <= sum[1]) {\n        return sum[1];\n      }\n    }\n\n    if (zero[0] == 0 && zero[1] > 0) {\n      if (sum[0] > sum[1] && sum[0] >= sum[1] + zero[1]) {\n        return sum[0];\n      }\n    }\n\n    // no zero\n    if (zero[0] + zero[1] == 0) {\n      if (sum[0] == sum[1]) {\n        return sum[1];\n      }\n    }\n\n    return -1;\n  }\n}\n```
['Java']