i undestand the problem logic but couldn’t write its recursive function during implementation part. i have even seen the hint video but unable to implenment.
pls guide me…
Recursion subset sum easy
@prince43055kumar
In this problem you just have to make all the subsets recursively and check if the sum of any subset is leading to zero or not.
So, basically for making element in the given array you have 2 choices whether to take that element in your subsets or not.
Recursive call will be like this:-
- If taking this current element then func(arr, i+1, sum+arr[i])
- not taking this, func(arr, i+1, sum)
Base case will be if possibility for all the elements is checked then done.
i.e. if(i==n) then check if sum==0 return true else false.
@prince43055kumar
I hope you have got some idea on how to implement it now. Feel free to ask for any confusion.
If now understood then please mark this doubt as resolved.
i have send the code pls review it there is minor problem.