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 = {\{ 1,2,3,41, 2, 3, 4 }\} and a target sum = 44. The output will be 2 as the following subsets:

  • {\{ 1,31, 3 }\}
  • {\{ 4 }\}

will add up to make the desired sum.

Constraints:

  • 11\leq nums.length 1000\leq 1000
  • 00\leq target_sum 25104\leq 25 *10^4
  • 11\leq nums[i] 104\leq 10^4

Examples

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.