The subset sum as target

without long long it runs but with long long it fails test cases

hello @Nooberz

pls save ur code here->


and share its link with me

code saved as per directions

its because of memory usage.
when u r declaring long long it is taking too much memory compared to when u declare bool and hence it is showing seg fault

try to solve in O(SUM) space complexity

but even if we don,t use long long on the dp array the test cases requires us to put long to use long long while taking input

now if i tread forth as per ur say it still showing segmentation fault

Constraints

1<= n <= 1000
1<= sum <= 10^5
1<= Ai <=10^4

int is sufficient to store ai ,sum.

make ur array global and then try.

thanks it is working 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.