Subset sum easy

getting correct outputs but not clearing the testcases

@Rakshitgarg99 There are mistakes in your recursive function.
In recursive case, you also need to check if the value return by any of them is 1 then it is possible else
return 0.
In base you also have check if(j==0) then not possible, but as here you just checking value of ans==0 which is already zero as taken.
No need to use this temp variable, useless.

for j==0 i use temp as if got more than 1 answer as zero we return the 1 or yes otherwise false
in submission section if i compile and test it shows correct answer but not in ide.codingblocks.com

if j==0 for i==n it means the subset is empty and we dont need to consider the empty subset, you need to handle this case.
also do the above change for recursive case, you code will pass, if you are facing issue in implementation then @Rakshitgarg99 can also ping me on chat.


change the code a little bit but still facing problem

https://ide.codingblocks.com/s/214338 this is the link of your code after doing all the above said modifications. See it and ask if you have any doubt.

why we add if statements for recursive cases

if statements are used to check if due to this recursive call the answer is possible or not.
They are just for optimization so that once we got the answer, it doesn’t need to do more.

@Rakshitgarg99 Mark this doubt as resolved, if your doubt is solved now.

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.