Let us jump into the implementation of minimum climate change problem, so in the input I have.
They said that they all types of coins I have and I will also take input, the number, the amount for
which I want to make the change of latency and Mazet and maybe we this as a barometer here.
So this is the total money for which we want to make the change.
Now, I'm just going to write the bottom up approach because top down is something more simpler and
similar also to let us just discuss the bottom up approach for this one in the bottom up approach.
We discussed that we will first rate the area.
And if you have to make change for M rupees, this area will be of the size and plus one to that.
The last indexers item, you one, two, three, four, five, six.
Up to.
So it does.
Initialise of Deepti.
And everything is going to be zero.
And the president is also going to be zero now for I'm going to trade from one till less than am I plus
plus and I can say I do not know for every state or for every state what we said.
If I want to see what is the minimum ways to make a change for I troops.
So we said we will make a call on a minus point of zero eight minus kind of one.
I mean, it's kind of to up to I mean, it's kind of big if we have any type of coin, OK, or a minus
one if we have.
Yes, both coins.
So coins, zero coins, one up to kind of three minus one.
And we will take a minimum of all these calls.
And we will add one to it.
So let us see how we can write this operation in terms of what we said, this under the zero hour,
one week.
OK, if I pick one rupee coin, what places I can land or at five I can see I can pick one looking five
rupee coin, I can go back to four or I can go back to zero.
Also, whatever answer is stored here or stored it, I take minimum of those to an advantage to that
particular answer.
And whatever is minimum, I store that answer here.
This is I do for every index from one to him.
So this is what we are going to do it so we can say that we do not know what is the minimum.
So we initialize the BPO, Vibert and Marks and for every type of coin that is there in the denominations
vector we can check.
Can we go back to this index?
So current index is I.
The jump that we are taking is off.
Sisay So we go back, see positions and check if this index is greater than equal to zero.
Only then we can use this particular value so we can say, OK, if it's there then maybe I will be minimum
of whatever is the minimum so far that is stored in the profi.
And what is the new answer.
So that will be of A minus C plus one.
Because we are also using one going here, we are going to this particular index and checking what is
the minimum gains needed to make Dunta for the B of A minus C plus one point because we are using this
theatergoing.
So are the KLEINWORT, whose value is C?
So finally, we consider the BP often there is one thing that you need to handle a corner case, and
this one is that if, let's say, your denomination contains only five and seven, and maybe then then
there is no way to make change for one, two, three, four or five, you need one convert 46, you
cannot make a change for basics.
OK, so for such cases, we will be storing infinitely Nevadans.
OK, so what we can do is we can handle such cases.
Also we can check.
If they of five minus the is not equal to earned marks, only then we should update our answer at six.
You make a call at four or you make a call at one end for one is not possible.
In that case, if you don't put this check, it would be infinity plus one, which would give you the
wrong answer.
OK, so in order to avoid this infinity plus one thing here, we need to add this particular logic.
And also we can say if BP often and Max, in that case we will deliver mean that no such responsible
by returning minus one, otherwise we will return deep of a deep form.
So this is BP of.
So that's it.
And that should.
But I made a mistake here, I made a mistake here.
This should go ahead.
So here we are retreating on in this.
If we we can make this.
Change.
Now, our goal is build and we can renovate also.
So you can see the answers to for me, was it because we can use a coin seven and coin one, we can
also try with a different denomination, let's say I want to make change for 16 rupees.
In this case, the answer should be three we can use in five and one, which is correct.
So that's all for this lecture.
I hope you really understood the bottom up approach as an exercise.
You can try implementing a top down approach on your own.
OK.