Tap here to switch tabs
Problem
Submissions

Problem: Minimum Equal Sum of Two Arrays After Replacing Zeros

Try to solve the Minimum Equal Sum of Two Arrays After Replacing Zeros problem.

Statement

You are given two arrays nums1 and nums2 consisting of integers greater than or equal to 00.

You must replace every 00 in both arrays with a strictly positive integer such that the sum of the elements in nums1 becomes equal to the sum of the elements in nums2.

Return the minimum equal sum that can be achieved, or −1-1 if it is impossible to make the sums equal.

Constraints:

  • 1≤1 \leq nums1.length, nums2.length ≤105\leq 10^5

  • 0≤0 \leq nums1[i], nums2[i] ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Equal Sum of Two Arrays After Replacing Zeros

Try to solve the Minimum Equal Sum of Two Arrays After Replacing Zeros problem.

Statement

You are given two arrays nums1 and nums2 consisting of integers greater than or equal to 00.

You must replace every 00 in both arrays with a strictly positive integer such that the sum of the elements in nums1 becomes equal to the sum of the elements in nums2.

Return the minimum equal sum that can be achieved, or −1-1 if it is impossible to make the sums equal.

Constraints:

  • 1≤1 \leq nums1.length, nums2.length ≤105\leq 10^5

  • 0≤0 \leq nums1[i], nums2[i] ≤106\leq 10^6