I can’t understand the base case of the solution. Help me!
Problem E Knapsack 2
@Rhinorox for base case we need to handle only for when i=1 and val=0 to max.
so, as for val it can be acheived by not taking any item, so dp[1][0]=0.
for val = value_of_item[1] , dp[1][val] is same as the weight of item 1.
for all the remaining values of dp[1][val] where val is from 0 to max, we cant make these values because we have only one item with some value so either we can use that item or not use that.
So for remaining cases we assign infinite val to dp[1][val]