Given a set of N items, each with a weight and a value, represented by the array w[] and val[] respectively. Also, a knapsack with weight limit W.
The task is to fill the knapsack in such a way that we can get the maximum profit. Return the maximum profit.Note: Each item can be taken any number of times.
- Time : O(nw)
- Space : O(w)
1 | class Solution { |