I would like to get an algorithm that gives me the best approximation for a value based on subset.
Here is an example:
N = 45
subset = [25,10,65,9,8]
output: [25,10,9]
The important point is that the algorithm must give the best approximation (regardless the number of the element in the final result). The result must provide the association that gives the exact value of the nearest (but can not exceed the initial value).
Do you know an algorithm that could do that with the minimal time cost ?
Thanks a lot for you help.