kindly make me understand this problem
Subset sum easy ymca
@Aug19APPPP0003
In this problem you get an array as input for each testcase and you have to find if there is a subset which sums up to 0.
Consider this testcase for a better understanding.
1
4
1 2 5 -3
Our Array is { 1 , 2 , 5 , -3 }
If you were to generate the all possible subsets of this array you would get a power set like
{
{ }
{ -3 }
{ 1 }
{ 2 }
{ 5 }
{ -3, 1 }
{ -3, 2 }
{ 1, 2 }
{ -3, 5 }
{ 1, 5 }
{ 2, 5 }
{ -3, 1, 2 }
{ -3, 1, 5 }
{ -3, 2, 5 }
{ 1, 2, 5 }
{ -3, 1, 2, 5 }
}
As you can see there is one subset whose elements if you add give you the sum 0 - { -3 , 1 , 2 }.
If there exists even one single subset which gives sum 0 , you should print “Yes”.
Otherwise print “No”
Hence the answer for this testcase would be “Yes”.
You can generate all these permutations using recursion and easily compute their sums.
@Aug19APPPP0003
Make sure to consider the case of the empty subset as the sum of empty subset will always be 0 so write your program as such that it does not consider the empty subset while deciding the final output of the program.