0/1 knapsack problem


3 testcases not passing
not able to find the error

Hello @nischay1111,

The memorization should be based on two parameters i.e. n and size.
IT is a question of 2D DP.

Even if you wanna solve it with 1D DP, you have to consider both n and size in account while memorization.

See the following article:
https://www.techiedelight.com/0-1-knapsack-problem/

Hope, this would help.

solved thanks a lot , Also i has a little doubt in count binary strings , can i ask that as well from you ?

Hey @nischay1111,

You can raise a separate doubt for that.
i’ll acknowledge it.
In case, someone else does it.
Then, ask it here.
Otherwise, mark it as resolved.