I need an effective algorithm to find a subset of integers within a set that meet the conditions:
- The sum of sub-set items <= the "limit"
- prefer to pick the subset with maximum values that fit the limit as close as possible.
Examples:
if the set after sort is {3,2,2} and "limit" is {4}, the subset would be {2,2}
if the set after sort is {3,2,2,1,1} and "limit" is {4}, the subset would be {3,1}
if the set after sort is {3,3,1} and "limit" is {5}, the subset would be {3,1}