The subsets sum to taget

mam mera code run error kyu dikhaa raha hai

hello @YASHMATHURIA123
check the constriant section.
in worst case ur dp array will use too much memory and that is why it showing run error.

to resolve it use linear dp. ->https://www.geeksforgeeks.org/subset-sum-problem-osum-space/

sir maine bhi tohyahi hi kara hai

image

tumhari space compelxity O(n*k)
jabki jo maine jo solution bheja hai uska linear.

isilye tumhara jayda space ki wajah se run error de raha hai

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.

sir why its still give me run error https://ide.codingblocks.com/s/288058

@YASHMATHURIA123 hey apne line 24 pr is jgah dp[j][i-a[j-1] , i-a[j-1] ko acess kia hai , it may happen it will be less than 0 at some moment so we will acess -ve index in that case so apply conditon that i-a[j-1] > =0 . Hope you get it.

sir its still gives me run error

@YASHMATHURIA123 hey check this code you will get to know the condition :https://ide.codingblocks.com/s/290723

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.