The input is two arrays, each one up to length 6 and each element in the array can be some number from [1, 2, 3, 4, 5, 6]. Return minimum number to change the arrays to make the sum of two arrays equal.
For example, A = [5, 4, 1, 2, 6, 5], B = [2]; return 6 because we can turn five dice in A to get [1, 1, 1, 1, 1, 1] and one dice in B to get [6]; then the arrays will have the same sums.
My first thought is to compute the sum of two arrays respectively: Sum(A) = 23, Sum(B) = 2.
Then the brute force way is compute required changes of making the sum equal to 2, 3, 4, ..., 23.
But I think the time complexity is too high.
The hard part of this problem is we do not know what the target sum we try to merge is.
Although in the given example, the minimum sum of A is 6, the max sum value of B is 6, so we know they will overlap at 6 so we can cut other branches.