Problem Challenge 1

Count of Subset Sum (hard) #

Given a set of positive numbers, find the total number of subsets whose sum is equal to a given number ā€˜S’.

Example 1: #
Input: {1, 1, 2, 3}, S=4
Output: 3
The given set has '3' subsets whose sum is '4': {1, 1, 2}, {1, 3}, {1, 3}
Note that we have two similar sets {1, 3}, because we have two '1' in our input.
Example 2: #
Input: {1, 2, 7, 1, 5}, S=9
Output: 3
The given set has '3' subsets whose sum is '9': {2, 7}, {1, 7, 1}, {1, 2, 1, 5}

Try it yourself #

Try solving this question here:

--NORMAL--

Output

0.471s

Total number of subsets -1 Total number of subsets: -1

Mark as Completed
←    Back
Minimum Subset Sum Difference (hard)
Next    →
Solution Review: Problem Challenge 1