n values given. Is there a possibility to have two Arrays A and B each containing elements from the given values such that the sum of all elements of A minus the sum of all elements of B gives the searched value? Each value can be used twice, but not twice in the same subset, so once in A and once in B at most (not necessary to use all the values in either A or B)
I was thinking of calculating every subsum and then, if one of the subsums is greater than the sum we want to reach, we search another subsum such that if we subtract it from the first sum we reach the searched value.
I don't think my idea is very efficient, nor dynamic. Any ideas how this problem could be solved dynamically?