### subset-sum

#### Clarification on subset sum

This is programming project for a class of mine, I'm not looking for an answer but more of an explanation of the problem. I don't really understand what is being asked.. Here is another input/ output: input: 1 2 3 3 4 5 output: 1 2 3 3 I don't understand how we are getting this output, can someone explain it to me simpler? Thanks

If the input is 1 2 3 3 4 5, the subsequences are: 1 1 2 1 2 3 1 2 3 3 1 2 3 3 4 1 2 3 3 4 5 2 2 3 2 3 3 ... Over all the subsequences, 1 2 3 3 is such that |(1 + 2 + 3 + 3) - (4 + 5)| = 0 is minimal. If we take the subsequence 2 3 3, we have |(2 + 3 + 3) - (1 + 4 + 5)| = |8 - 10| = 2 which is greater. However, I'm also confused by the meaning of "subsequence". I thought that, the subsequences of 1 2 3 4 5 should be: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 2 2 3 2 3 4 2 3 4 5 3 3 4 3 4 5 4 4 5 5 But according to the subject, the optimal subsequence is 1 2 4 which is not in my list. It's in fact a subset of the set S. So be careful, there are many combinations.

### Related Links

Subset sum with dynamic programming

Reducing Subset Sum Problm

Clarification on subset sum

Subset whose sum is the smallest sum over a specific threshold