0

Given a total and an array of integers what is the best algorithm to find the subset of integers whose sum is equal or closest to the total? Subset sum problem only tells whether it's possible to achieve the total or not . In this problem in case that fails I have to calculate the subset whose sum is closest to the total?

For example

Given total =100 
And integers as  { 20,30,40,55 } 
The Correct answer should be 95 {40+55}

Is there an algorithm to calculate this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Aman Kumar Sinha
  • 407
  • 6
  • 17

0 Answers0