Hi, everyone, welcome to this new video.
So as discussed, what we are going to do, we are going to write the code for solving this problem.
That is the first code for finding out the minimum number of moves.
Right.
And we are going to copy this code shortest part in binary matrix.
So first thing that I want to change here is so these variable names are very, very, very bad.
So these are Ambros McCrossin, right?
Just bodies of size, McCrossin.
So this is the starting vertex.
So sors coordinate X, right.
This is why this is your target X.
And this is your target line, basically destination X, coordinate our destination, and Y, coordinate
over destination, right.
So let's copy the code.
So first, let us copy this code cell.
So I have this cell here, so instead of distance, we need to find out the minimum number of moves.
So I am renaming this variable to moves right there to find out the minimum number of moves I am renaming.
This distance is also fine, but moves a little bit better.
So that changed.
And now let's copied this.
Let's copy this so great of zero zero.
We do not need this condition, so let's be clear, this condition, we need to change the X coordinate
and make ordinate according to the Knight Move.
So Knight move in 2.5 moves, 2.5 steps eight.
So it will be let me change it when it seems fine.
This will be minus two.
One is correct.
Two and similarly, let's change the Y coordinate minus seems fine.
It should be minus two.
Then we will have minus one.
This one.
That's Alberto.
That's Alberto and one.
Yes that's correct.
So no, we do not need to find out the size.
Victor Estrada.
Yes there is Ambrose and since it is one indexed so M plus one and not in columns and plus one columns
because one indexing one indexed based.
Right you sell goodhart Bush.
We need to push these sort of artex.
So Source X coordinate and source VI coordinate.
And what is the number of moves.
Number of moves out.
Zero visited.
So coordinate X and Y has been visible so marking them as true value is not empty.
Friend Bob temporary dot x is a close to where do we want to reach.
We want to reach the target x coordinate and target via coordinate.
If that is correct, we will return the namaroff moves.
So I list.
I need the new coordinate.
New Y coordinate.
We need to change this condition.
Indexing is one next beast.
This will be less than close to M number of rules.
Indexing is one based less than articles two and grade of x y equals zero.
No, we do not need this condition.
There is nothing called great here.
Visitor.
Yes, this is moves visited of x y to.
And finally, if I'm not able to reach a destination, then we're done minus one.
Yep.
So we have modified the code.
Let's test our code and if everything seems fine, then we'll submit.
Yep, so I'll go pass the basic test cases, let somebody.
Yeah, so our goal is working.
And let's quickly grow to the entire record.
It's pretty simple, exactly like we did earlier.
So again, what is this, the system we need to sell?
Right.
Excoriated by coronate and a number of moves.
So each sale will contain extraordinary recorded and the number of moves required from Soules point
to reach this Cellebrite.
Very simple.
After that, what I am doing.
So we need to find out the next direction and the change in direction.
So there are total possible eight direction in which not just sort of in which the knight can move.
So I have a better these stories.
Again, we need to be ready.
And since the indexing is one based.
So that's right.
And plus one does and and plus one, we need to initialize the default, then we need to create a queue
of sell.
We will insert this source.
I'm standing at these sorts of attacks, so insert the source and the number of moves is currently zero.
We need to mark this.
Sellers visited then while the queue is not empty.
So again, a different element, Bob, if the current coordinate is it goes to the destination, the
target and that target date than the number of moves.
Otherwise we can move in each direction from the current cell and find out the new extraordinaire.
New Y coordinate then basic condition should bigger than when they close to him should be bigger than
one.
And the Y coordinates question.
And this coordinate this cell has not been visited before.
If that is correct, you will push the cell in the queue by increasing the number of moves.
Plus one, make the visitor for this cell to be true.
And that's it.
Right.
This is exactly like the previous problem, very similar to that one.
Right.
So that is a device I will share the with you.
So this is all about this video, if you have any doubt in this question to ask me, I will be more
than happy to help you out.
So I will see you in the next one.
Thank you.