PEC-CSS/Open-Source

Equalize Array Sums with Minimal Updates

ultimatecoder2 opened this issue · 1 comments

You are given two array of integers a and b where every element in both lists is between 1 to 6. Consider an operation where you pick a number in either a or b and update its value to a number between 1 to 6.

Return the minimum number of operations required such that the sum of a and b are equal. If it's not possible, return -1.

Sample Test Case

INPUT:
a = [1, 5]
b = [6, 5, 5]

OUTPUT:
2

EXPLANATION:
If we change the 1 to 6 in a and the 6 to 1 in b, then both of their sums would be 11.

I can work on this. Can you assign me this task? I would like to code in Java.