Problem Brief
Balancing Teams
FULLTIMEOA
Two teams have skill arrays teamA and teamB. A value of 0 means that player slot is empty.
Fill every empty slot with a positive skill value no larger than 10000 so that both teams end with the same total skill. Return the minimum possible equal team sum, or -1 if no such assignment exists.
1Example 1
Input
teamA = [5, 10, 0, 4], teamB = [2, 4, 0, 5, 0]
Output
20
Explanation
Fill the zero in teamA with 1, and the zeros in teamB with 3 and 6. Both teams then sum to 20, which is the minimum equal sum.
Constraints
Limits and guarantees your solution can rely on.
1 <= n, m <= 10^50 <= teamA[i], teamB[i] <= 10^4