Subset sum easy recurssion

whats error in this code?

hello @nilotpal

check now->

pls exlain return subsetsum(a,i+1,n,sum,cnt) || subsetsum(a,i+1,n,sum+a[i],cnt+1); this line.

Since we have to call both the reccurssive fn, why are we using OR?

we have two cases and we dont know which case will generate sum =0.
so we are trying both case. and if any of them return true then return true from here as well.

thats why written or in between

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.