FB Technical Phone Screen Interview question for Netwrok Optimization role.
Find all possible combination of array subset which result in target variable. repeat of elements is permitted
arr = [1,2,6,3,5,7,9], target = 7 return [7] , [2,5], [1,6], [2,2,3]
I was able to get a brute force answer. When asked about optimizing the solution I spoke of 2 pointer techniques, dynamic programming method etc.
What should be the optimal solution?