Runtime Error in subset sum target problem

I am getting Run Error in solving this problem in the first two cases.Kindly suggest me the way to complete the problem.

Link of code is

Try and initialize the first row and first column of the dp matrix seperately and then fill the values for the rest of the dp matrix .
The logic is correct must be some problem with the order of if and else statements .
Try separating the trivial subproblems ( the first row and column) and ask if you have any other queries .
I hope this helps . Have a nice day :blush: if your doubt is resolved please mark it as resolved and rate me accordingly

Sir , I am still getting runtime error after tried everything i can.Kindly tell me what the problem is.

Please share your updated IDE link . I will have a look

https://ide.codingblocks.com/s/316903…Here is my updated code.Please sir see to it and tell me what the actual problem is.

bool dp[1001][100001]={0};

declare your dp matrix globally the dynamic declaration of the dp matrix is causing the program to give runtime error as it is not able to create such large amount of memory(contigious) at runtime .
It will work for sure .
Hope this helps :blush:
Please mark the doubt as resolved if the doubt is resolved and rate me accordingly . Thankyou

thanks sir for helping me to solve this ques.

1 Like