C# algorithm - find least number of objects necessary

后端 未结 6 1108
孤街浪徒
孤街浪徒 2021-01-14 03:19

Let\'s say I have the following code.

var numberToGetTo = 60; 
var list = new[] {10, 20, 30, 40, 50};

I want to be able to return 50 &

6条回答
  •  没有蜡笔的小新
    2021-01-14 04:12

    Knapsack Problem, this may give you a clue.

    http://en.wikipedia.org/wiki/Knapsack_problem

    I'd say that you could create a lambda expression containing the actual alogrithm, but you'll need to use C#. Using 'just linq' will not be enough.

提交回复
热议问题