Https://ide.codingblocks.com/s/270444

3 test cases are not passing

@J20APPPP0006 you are using recursion therefore, it will get tle, instead try using n^2 approach .

but i used dp (dynamic prpgramming)too

??..please reply and tell the issue

Make a 2d Dp to store all the values dp[ithItem][ weight] . Then you can store the correct dp values and it wont give you a wrong answer.

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.