1
00:00:00,930 --> 00:00:02,969
Hi, everyone, welcome to this new video.

2
00:00:03,330 --> 00:00:08,310
So as discussed, what we are going to do, we are going to write the code for solving this problem.

3
00:00:08,460 --> 00:00:12,090
That is the first code for finding out the minimum number of moves.

4
00:00:12,360 --> 00:00:12,720
Right.

5
00:00:12,870 --> 00:00:16,450
And we are going to copy this code shortest part in binary matrix.

6
00:00:16,470 --> 00:00:24,640
So first thing that I want to change here is so these variable names are very, very, very bad.

7
00:00:24,660 --> 00:00:27,900
So these are Ambros McCrossin, right?

8
00:00:28,350 --> 00:00:30,170
Just bodies of size, McCrossin.

9
00:00:30,180 --> 00:00:32,070
So this is the starting vertex.

10
00:00:32,340 --> 00:00:34,370
So sors coordinate X, right.

11
00:00:35,340 --> 00:00:40,410
This is why this is your target X.

12
00:00:41,470 --> 00:00:47,200
And this is your target line, basically destination X, coordinate our destination, and Y, coordinate

13
00:00:47,200 --> 00:00:48,230
over destination, right.

14
00:00:48,370 --> 00:00:49,970
So let's copy the code.

15
00:00:50,710 --> 00:00:53,560
So first, let us copy this code cell.

16
00:00:58,390 --> 00:01:03,310
So I have this cell here, so instead of distance, we need to find out the minimum number of moves.

17
00:01:03,580 --> 00:01:09,700
So I am renaming this variable to moves right there to find out the minimum number of moves I am renaming.

18
00:01:09,700 --> 00:01:13,010
This distance is also fine, but moves a little bit better.

19
00:01:13,300 --> 00:01:14,130
So that changed.

20
00:01:14,980 --> 00:01:16,930
And now let's copied this.

21
00:01:23,450 --> 00:01:27,270
Let's copy this so great of zero zero.

22
00:01:27,710 --> 00:01:35,000
We do not need this condition, so let's be clear, this condition, we need to change the X coordinate

23
00:01:35,000 --> 00:01:37,230
and make ordinate according to the Knight Move.

24
00:01:38,030 --> 00:01:44,270
So Knight move in 2.5 moves, 2.5 steps eight.

25
00:01:44,750 --> 00:01:48,890
So it will be let me change it when it seems fine.

26
00:01:49,370 --> 00:01:50,690
This will be minus two.

27
00:01:52,550 --> 00:01:53,660
One is correct.

28
00:01:53,660 --> 00:01:58,790
Two and similarly, let's change the Y coordinate minus seems fine.

29
00:01:59,610 --> 00:02:00,980
It should be minus two.

30
00:02:01,370 --> 00:02:03,440
Then we will have minus one.

31
00:02:03,890 --> 00:02:04,730
This one.

32
00:02:05,250 --> 00:02:06,130
That's Alberto.

33
00:02:06,820 --> 00:02:08,180
That's Alberto and one.

34
00:02:08,270 --> 00:02:09,340
Yes that's correct.

35
00:02:09,530 --> 00:02:12,620
So no, we do not need to find out the size.

36
00:02:15,590 --> 00:02:16,960
Victor Estrada.

37
00:02:16,970 --> 00:02:25,940
Yes there is Ambrose and since it is one indexed so M plus one and not in columns and plus one columns

38
00:02:25,940 --> 00:02:29,240
because one indexing one indexed based.

39
00:02:29,240 --> 00:02:32,770
Right you sell goodhart Bush.

40
00:02:32,780 --> 00:02:34,820
We need to push these sort of artex.

41
00:02:35,150 --> 00:02:38,240
So Source X coordinate and source VI coordinate.

42
00:02:38,600 --> 00:02:40,370
And what is the number of moves.

43
00:02:40,370 --> 00:02:41,360
Number of moves out.

44
00:02:41,420 --> 00:02:44,870
Zero visited.

45
00:02:46,820 --> 00:02:54,110
So coordinate X and Y has been visible so marking them as true value is not empty.

46
00:02:54,110 --> 00:03:00,920
Friend Bob temporary dot x is a close to where do we want to reach.

47
00:03:00,920 --> 00:03:07,700
We want to reach the target x coordinate and target via coordinate.

48
00:03:07,940 --> 00:03:11,900
If that is correct, we will return the namaroff moves.

49
00:03:13,310 --> 00:03:14,440
So I list.

50
00:03:14,440 --> 00:03:16,340
I need the new coordinate.

51
00:03:16,340 --> 00:03:17,240
New Y coordinate.

52
00:03:17,240 --> 00:03:18,650
We need to change this condition.

53
00:03:18,650 --> 00:03:20,270
Indexing is one next beast.

54
00:03:21,470 --> 00:03:24,050
This will be less than close to M number of rules.

55
00:03:24,890 --> 00:03:31,340
Indexing is one based less than articles two and grade of x y equals zero.

56
00:03:31,340 --> 00:03:32,960
No, we do not need this condition.

57
00:03:32,960 --> 00:03:34,430
There is nothing called great here.

58
00:03:35,190 --> 00:03:35,810
Visitor.

59
00:03:35,840 --> 00:03:41,840
Yes, this is moves visited of x y to.

60
00:03:44,910 --> 00:03:49,500
And finally, if I'm not able to reach a destination, then we're done minus one.

61
00:03:50,280 --> 00:03:50,730
Yep.

62
00:03:50,740 --> 00:03:52,380
So we have modified the code.

63
00:03:52,560 --> 00:03:56,160
Let's test our code and if everything seems fine, then we'll submit.

64
00:03:59,600 --> 00:04:04,150
Yep, so I'll go pass the basic test cases, let somebody.

65
00:04:05,470 --> 00:04:07,390
Yeah, so our goal is working.

66
00:04:07,600 --> 00:04:10,060
And let's quickly grow to the entire record.

67
00:04:10,690 --> 00:04:13,910
It's pretty simple, exactly like we did earlier.

68
00:04:15,580 --> 00:04:18,399
So again, what is this, the system we need to sell?

69
00:04:18,399 --> 00:04:18,730
Right.

70
00:04:18,730 --> 00:04:20,880
Excoriated by coronate and a number of moves.

71
00:04:21,250 --> 00:04:27,880
So each sale will contain extraordinary recorded and the number of moves required from Soules point

72
00:04:27,880 --> 00:04:29,620
to reach this Cellebrite.

73
00:04:29,620 --> 00:04:30,290
Very simple.

74
00:04:30,340 --> 00:04:31,690
After that, what I am doing.

75
00:04:31,900 --> 00:04:36,300
So we need to find out the next direction and the change in direction.

76
00:04:36,310 --> 00:04:40,980
So there are total possible eight direction in which not just sort of in which the knight can move.

77
00:04:41,230 --> 00:04:43,110
So I have a better these stories.

78
00:04:43,490 --> 00:04:45,030
Again, we need to be ready.

79
00:04:45,040 --> 00:04:46,960
And since the indexing is one based.

80
00:04:46,960 --> 00:04:47,500
So that's right.

81
00:04:47,500 --> 00:04:53,200
And plus one does and and plus one, we need to initialize the default, then we need to create a queue

82
00:04:53,200 --> 00:04:53,670
of sell.

83
00:04:54,160 --> 00:04:55,600
We will insert this source.

84
00:04:55,630 --> 00:05:01,030
I'm standing at these sorts of attacks, so insert the source and the number of moves is currently zero.

85
00:05:01,330 --> 00:05:03,430
We need to mark this.

86
00:05:03,440 --> 00:05:06,100
Sellers visited then while the queue is not empty.

87
00:05:06,400 --> 00:05:13,390
So again, a different element, Bob, if the current coordinate is it goes to the destination, the

88
00:05:13,390 --> 00:05:16,330
target and that target date than the number of moves.

89
00:05:16,810 --> 00:05:22,040
Otherwise we can move in each direction from the current cell and find out the new extraordinaire.

90
00:05:22,150 --> 00:05:27,730
New Y coordinate then basic condition should bigger than when they close to him should be bigger than

91
00:05:27,730 --> 00:05:27,940
one.

92
00:05:27,940 --> 00:05:29,620
And the Y coordinates question.

93
00:05:29,800 --> 00:05:32,980
And this coordinate this cell has not been visited before.

94
00:05:33,280 --> 00:05:39,100
If that is correct, you will push the cell in the queue by increasing the number of moves.

95
00:05:39,100 --> 00:05:43,510
Plus one, make the visitor for this cell to be true.

96
00:05:43,690 --> 00:05:44,500
And that's it.

97
00:05:44,950 --> 00:05:45,400
Right.

98
00:05:45,610 --> 00:05:49,630
This is exactly like the previous problem, very similar to that one.

99
00:05:49,630 --> 00:05:50,020
Right.

100
00:05:50,590 --> 00:05:53,830
So that is a device I will share the with you.

101
00:05:55,300 --> 00:05:59,740
So this is all about this video, if you have any doubt in this question to ask me, I will be more

102
00:05:59,740 --> 00:06:00,760
than happy to help you out.

103
00:06:00,850 --> 00:06:02,320
So I will see you in the next one.

104
00:06:02,350 --> 00:06:02,920
Thank you.

