Optimizing subset sum implementation

后端 未结 3 1952
一向
一向 2020-12-11 13:58

I\'m working on a solution to a variant of the subset sum problem, using the below code. The problem entails generating subsets of 11 ints from a larger set (superset) and c

3条回答
  •  盖世英雄少女心
    2020-12-11 14:23

    I don't think there is a way to generate the unique subsets in better than exponential time.

    To solve subset-sum efficiently you want to use dynamic programming. There are some pseudo-polynomial time algorithms for subset-sum that work this way. This Wikipedia article might help.

提交回复
热议问题