i would like the solution to this qs with explanation
Subset Sum Easy qs
hey khushi
first you yourself give it a try. if you face any difficulty in solving the question you can message me.
you can think in the following way
Let isSubSetSum(int set[], int n, int sum) be the function to find whether there is a subset of set[] with sum equal to sum. n is the number of elements in set[].
The isSubsetSum problem can be divided into two subproblems
…a) Include the last element, recur for n = n-1, sum = sum – set[n-1]
…b) Exclude the last element, recur for n = n-1.
If any of the above the above subproblems return true, then return true.
This above approach is for problem where sum=some integer
you can refer the above logic and make the necessary changes according to the given problem