Subset sum to target

one test case is giving incorrec tanswer . I have used bitmasking approach to solve the question.

Hi @Vishal123,
can u pls share ur code through ide.codingblocks.com inorder to check why u r getting one incorrect answer.

Hi @Vishal123,
ur code is fine. But it will only work if n<=30. since u r using 1<<n, if n>=30, 1<<n value will exceed 10^9 and hence would not be stored in an integer. in this question n<=5000.
So, in order to optimize ur code, try dp approach. make a 2d dp[array index][target value].
If u face any problem in dis , u can post ur problem here.
Hope dis resolves ur doubt

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.