Recently in an interview i was asked this question.
Given:
a + or - b = 40 // You can choose any one operator + or -
[list of any numbers in an array]
Explain how will you choose numbers for A and B from an given array to make the result 40 ?
My Answer:
Consider 1st element of array as A, now iterate through array from start to find possible values of B while this process fetch each element from array, sum up with A and compare it with 40.
But he was not happy.
Any other approaches ?