Given an array of integers, find a sum from those given integers such that the value of sum maximized but smaller than or equal to x (given that x is <= total sum of values of array). Can anyone help me?
It looks like some kind of the knapsack problem.
Exactly For example, very similar problem: https://stackoverflow.com/questions/18066624/maximum-sum-of-a-subset-of-size-k-with-sum-less-than-m