I need some hints to find an algorithm that returns 5
elements whose sum is closest or equal to a given number.
Those elements are numbers greater than 0
and shall be "used" only 1 time each when trying to get the given number.
Let's say we got an array {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
and the number we're trying to get 21
. It should returns {2, 3, 4, 5, 7}
.
Any help is greatly appreciated!