Getting Run error in second test case

I’m getting run error in second test case, I don’t know why. My code is working fine on other platforms. Please help!
My code: https://ide.codingblocks.com/s/241468

@devaman1729 ya its because sum is very large and you cannot make a array of size=n*sum.
Here you need to optimize the space.
what you can do is to take a dp[2][sum+1], because if you see the recurrence relation then for dp[i][j] either you need to have the answer for dp[i-1] or dp[i], i.e. you never need to go dp[i-2] or something.

@devaman1729
You can also just declare the bool dp array globally, it will solve your issue.

We have to use dynamic 2D array(dp array) then all the test cases are passing succesfully.

@devaman1729
Have you solved it now?
please mark the doubt as resolved if you have solved it now.

Yes, Thank you!
:slightly_smiling_face:

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.