educative.io

More clarification on size of dp[][] array for 0/1 knapsack - dp[capacity+1][profit]

could someone kindly explain why the size of dp[][] array for knapsack is dp[capacity+1][profit]?

1 Like

int profits[] = {1, 6, 10, 16}; // The values of the jewelry
int weights[] = {1, 2, 3, 5}; // The weight of each

Why are the size of arrays different?
(https://www.educative.io/courses/algorithms-coding-interviews-java/myxqGZp4Rr0)