Subset sum easy

https://ide.geeksforgeeks.org/jIfAPFPpZt
why is my code giving wrong ans

@anitagupta1411 why are you doing exit(0) ? If you do that the program will terminate and rest of the test cases will not be executed.

then what should i do?

@anitagupta1411 you can have a return type of bool, and return true if answer is found and if you hit the base case without finding answer, return false.

https://ide.geeksforgeeks.org/2mivz9lMbi

https://ide.geeksforgeeks.org/2mivz9lMbi now also giving wrong ans

hi @anitagupta1411 this approach is not correct, you are not checking all subsets this way and calculating sum again and again is also very inefficient, please see this approach: https://ide.geeksforgeeks.org/5cNxKzTD9V

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.