I've been asked the following question in an interview. Although I've answered it using an n-ary tree, I've been told it wasn't "good enough". So, I'm curious, what's the optimal solution for it.
Input: array of integers: [2, 3, 7] and sum: 10
Output: all combinations of array elements that add up to sum (e.g. 2+2+2+2+2, 2+2+3+3, 3+7, etc.)
Thanks, T