My code is not working .... Can you help me in this

hello @sukritbansal01
ur code will always return true because u r considering empty subset as well.
but forr this problem u need to print true only if there exist non empty subset with sum 0.
handle this case and ur code will work fine

Yeah I figured out that …
But i am unable to correct it

simply add one more variable in ur function for maintingin thee count of elements in ur subset.

if u are adding current element in ur subset then increments its value by one.
other wise pass the same value without increment.

now in base case check for two cases.
if sum==0 and count > 0
return true
otherwise
return false

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.