some of my test cases are showing runtime error!
Some of my test cases are showing runtime error!
Your code is giving runtime error because you have tried to create an array of large size during runtime. See maximum value of n is 10^5 and k is 5000. In your code you have tried to create dp[n+1][k+1], for maximum value of n and k it become dp[100001][5001] which can’t be possible. We don’t have that much memory allocated for such question.
Refer this https://www.geeksforgeeks.org/subset-sum-problem-osum-space/
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.