Find out which combinations of numbers in a set add up to a given total

后端 未结 8 1149
旧时难觅i
旧时难觅i 2020-12-01 08:11

I\'ve been tasked with helping some accountants solve a common problem they have - given a list of transactions and a total deposit, which transactions are part of the depos

8条回答
  •  臣服心动
    2020-12-01 08:44

    Its kind of like 0-1 Knapsack problem which is NP-complete and can be solved through dynamic programming in polynomial time.

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

    But at the end of the algorithm you also need to check that the sum is what you wanted.

提交回复
热议问题