3

I have given an array.And i want to find the all permutation of an array so it sum to a specific numbers.
Example
Array a =[2,3,5 ,1]
Target = 8
`Solution: [2,2,2,2] ,[5,3] ,[3,3,2] ,[5,2,1] and all possible combination
Please provide me a approach to solve this the problem , the problem i am facing how to handle the repetition of the elements.Target is a large number of 10^6. I think it is same asThis theory

Bad Coder
  • 866
  • 1
  • 12
  • 27

1 Answers1

1

You are facing a typical Subset Problem. The worst case complexity of this problem is exponential no matter how you put it. You might find good polynomial-time approximations that work wonders for average case though.

Ajk_P
  • 1,874
  • 18
  • 23