Code showing Wrong Answer for 3 Test Cases

The code is showing error for three test cases…and i am unable to figure out what my mistake is. Please help me in pointing out my mistake. Thank You!

Hey @paulayush2002
This is a 2D DP question
There are two states involved one is weight and another is array index
Use 2d dp and ur code will work good

Thank You,for the Help!!

1 Like