Given finitely encoded nonnegative integers and target , the subset sum problem asks whether some subset sums to . Taking equal item weights and profits reduces it to testing whether a 0-1 knapsack problem with capacity attains value .
For indexed occurrences with positive integer weights, let record whether a subset of the first entries has sum . The recurrence chooses whether the last occurrence is absent or present: , with an out-of-range term false. Initialize only sum zero true. Descending one-dimensional updates prevent reusing the current occurrence. Time is for target and space ; positivity permits immediate rejection above the total. With weights bounded by , the total is at most , making the bound polynomial in .
A finite set of positive integers such that nonempty disjoint sets contained in have different sums, and the larger subset has the larger sum when their sizes differ. For , the size condition is equivalent to for : the left side is the smallest possible sum of elements and the right side the largest sum of elements.