Suggest I have the following array :
{2,3,4,5,11,6} and I'd like to know if any items of the array contain a sum of the number x.
For example: x=10, then the output would be {2,3,5} and {4,6}. x=13, then the output would be {2,11},{3,4,6} and {2,5,6}
What would be an optimal algorithm to solve this problem?
I have thought of solving this using the possible permutations of the array, and check whether the sum of the beginning of each permutation equals to the X, but it doesn't seem to solve it.
Thanks!