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
Getting Run error in second test case
@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.
We have to use dynamic 2D array(dp array) then all the test cases are passing succesfully.
Yes, Thank you!

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.