Welcome back.
In this video, let's get started with another interesting coding interview question, which is called
the Unbounded Knapsack question.
The question reads you are given a set of n items, each with a weight and a value represented by the
array w, t, and val respectively, and 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, okay, and it says.
Note each item can be taken any number of times.
So this is how this question is different from the zero one knapsack problem which we have previously
discussed.
So over here we're given an example.
So let's say we are given just two items.
And the value of those two items are five and ten respectively.
And their respective weights are two and two.
Okay.
Now if this is the case and if the maximum capacity of the given knapsack is six units of weight, then
the required output would be 30, because you can just take three of these items okay.
So if this is item one and let's say this is item two okay.
So you can just fill three units of item two into the knapsack.
So you have a knapsack and you have item two.
And again you have item two.
And again you have item two okay.
Now notice that the value of the items in the knapsack is ten plus ten plus ten.
Because each item has a value of ten.
And at this point, the total value of the items in the knapsack is equal to 30.
And this is the desired output as per the question.
And again at this point, notice that the total weight of the items in the knapsack is two plus two
plus two, which is less than or equal to six.
So this is the condition given in the question.
And this is actually six.
And six is less than or equal to six.
So the condition is also satisfied.
So this is the question at hand.
In the next video let's discuss how we can solve this question.