Equal sum subsets hybrid

前端 未结 4 1995
星月不相逢
星月不相逢 2020-12-18 02:10

The problem is the following:

You are given a set of positive integers { a1 , a2 , a3 , ... , an } in which there are no same numbers ( a1 exists only once ,a2 exist

4条回答
  •  天命终不由人
    2020-12-18 02:48

    If the answer is no, then the sum of all n numbers is at least 2^n-1. So if n is large, and the numbers are 32-bit integers, for instance, then the answer is almost always yes. If n is small, you can probably brute-force.

    The hardest case is probably when n is around 30.

提交回复
热议问题