Count of Subset Sum
Let's solve the Count of Subset Sum problem using Dynamic Programming.
Statement
Given a set of positive numbers nums
and a value target_sum
, count the total number of subsets of the given set whose sum is equal to the target_sum
.
Let’s say you are given a set = and a target sum = . The output will be 2 as the following subsets:
- 4
will add up to make the desired sum.
Constraints:
-
nums.length
-
target_sum
-
nums[i]
Examples
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.