- as soon as sum becomes zero then return
- empty subset return sum zero
how to handle these two cases ?
Subset sum easy
for 1) use the return type of your function as bool, so if sum==0 then return true.
for 2) use extra parameter with in the function, which will denote the number of element you have taken in the subset, so just modify you base condition like if(sum==0 && extra_parameter!=0) return true.
I hope you will be able to solve it now.
Please mark this doubt as resolved if you will be able to solve it after this.
1 Like
is this correct way?
1 Like