Help with approach

code: https://ide.codingblocks.com/s/425032

problem: https://hack.codingblocks.com/app/contests/2022/370/problem

I would like to know where is this code not working please give a hint at first not the entire code

initially I thought when you have tried all the elements ( n == 0) and sum != 0 return false but it gave the wrong answer

Okay your recursive calls were incorrect. I corrected these please see https://ide.codingblocks.com/s/425081.

But your solution will give TLE for larger cases. You need to do subset sum dp.

If you can’t think of an approach follow this link https://www.geeksforgeeks.org/subset-sum-problem-dp-25/

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.