Is there an efficient algorithm for integer partitioning with restricted number of parts?

前端 未结 5 886
天涯浪人
天涯浪人 2020-12-01 11:32

I have to create a method that takes two integers, let them be n and m, and returns how many ways there are to sum m positive numbers

5条回答
  •  暖寄归人
    2020-12-01 12:13

    this problem seems to be SubSet Sum Problem

    its an NP problem meaning all the solutions would be non-deterministic (i.e. there isn't any known efficient algorithm).

    you can however try some heuristic approach and find some satisfying results in a more efficient way.

提交回复
热议问题