There are 2 arrays where the length of both arrays are the same.
array A = set of non-negative integers
array B = set of non-positive integers
I must either select A[i] or B[i] for each index i and want to know the minimum of abs(sum).
e.g
example 1
A = {1,2,3,4} , B = {-1,-2,-3,-4}
then the minimum of abs(sum) would be 0 by selecting 1, -2, -3 and 4. (-1, 2, 3, -4) also works.
example 2
A = {1,1,1,3} , B = {0,0,0,-3}
then the minimum of abs(sum) would be 0 by selecting 1,1,1 and -3.
I can only think of naive way of computing every possible combinations which takes exponential time. Could there be any better approach for this problem?