Sir doubt in knapsack

sir why is this code failing 3 cases??

hello @tejasddongare

checking. . . . … . …

@tejasddongare

ur inner loop should run till j<=bag_capacity

check ur updated code here->

sir but why will it make difference its an extra part in dp which we wont even consider than why does that work?

ur dp is of size

dp[size][bag_capacity] right?

but u r intilaising only upto dp[size][size], some part will remain uninitialise (may contain garbage value) due to which u will get wa