1
00:00:02,240 --> 00:00:02,910
Hi, everyone.

2
00:00:02,930 --> 00:00:06,390
So in this video, we're going to solve this question jump game two.

3
00:00:06,410 --> 00:00:10,760
So basically this question is a modification of the old question that we have done.

4
00:00:11,060 --> 00:00:17,600
So in this question, what we have to do so instead of telling instead of returning, true or false,

5
00:00:17,870 --> 00:00:22,760
whether I will be able to reach the last looks or not, I have to return the minimum number of jumps

6
00:00:22,760 --> 00:00:25,760
to reach the last index of this example.

7
00:00:26,060 --> 00:00:29,380
So we consider this example in our last problem also.

8
00:00:29,930 --> 00:00:34,670
So I told you, there are two ways to reach the last question first, which is basically take a jump

9
00:00:34,670 --> 00:00:36,980
of one, then take a jump of three.

10
00:00:37,580 --> 00:00:40,190
So how many times are required to jump sideward?

11
00:00:40,520 --> 00:00:46,070
But if it will take a jump of two, then you will take a jump often, then you will take a jump, often

12
00:00:46,070 --> 00:00:46,100
one.

13
00:00:46,250 --> 00:00:49,010
So in this way there are three jumps required.

14
00:00:49,250 --> 00:00:50,990
So what we have to do, you can see.

15
00:00:51,320 --> 00:00:56,090
So we have to reach the last indexing, the minimum number of jumps in the number of times I have to

16
00:00:56,090 --> 00:00:59,150
reach the last index and I would return the minimum number of jumps.

17
00:00:59,150 --> 00:01:00,780
So the number of jumps are too.

18
00:01:01,400 --> 00:01:03,560
So among the entry two is the minimum.

19
00:01:03,830 --> 00:01:06,020
So my answer in this case will be two.

20
00:01:06,230 --> 00:01:07,160
So two is my answer.

21
00:01:07,160 --> 00:01:09,890
Two is the minimum number of jumps that I will require.

22
00:01:10,520 --> 00:01:12,620
Now let's see how we can solve this problem.

23
00:01:15,600 --> 00:01:22,350
So let us take a big example to understand the situation, one, four, three, seven one, then let's

24
00:01:22,350 --> 00:01:25,890
say I have two, six, seven, six and 10.

25
00:01:26,110 --> 00:01:30,590
OK, so initially I'm standing here and I want to reach here.

26
00:01:31,200 --> 00:01:32,820
So let us take two variables.

27
00:01:32,910 --> 00:01:39,760
Current ladder and basically the biggest current ladder and biggest ladder.

28
00:01:40,380 --> 00:01:46,560
OK, so for one, the biggest ladder is basically I will be able to reach for four four and what will

29
00:01:46,560 --> 00:01:47,480
be the biggest ladder.

30
00:01:47,490 --> 00:01:54,400
So it will be I will be able to reach to OK from four I will be able to reach two.

31
00:01:54,420 --> 00:01:55,710
So this is the biggest ladder.

32
00:01:55,710 --> 00:01:56,870
Four four four three.

33
00:01:56,880 --> 00:01:58,030
What will be the biggest ladder.

34
00:01:58,050 --> 00:02:00,390
So this will be the biggest ladder for tree.

35
00:02:01,450 --> 00:02:07,600
Four, seven, so this is one, two, three, four, five, six.

36
00:02:08,520 --> 00:02:12,130
And then seven, so four seven, this is the biggest letter for one.

37
00:02:12,780 --> 00:02:15,320
This is the biggest letter for two.

38
00:02:15,870 --> 00:02:17,570
So this will be one and two.

39
00:02:18,180 --> 00:02:19,910
OK, now for six.

40
00:02:20,490 --> 00:02:22,080
So one, two, three.

41
00:02:22,080 --> 00:02:23,610
And then four, five and six.

42
00:02:24,540 --> 00:02:32,970
Now 47, so when two, then three, four, five, six, seven, OK, and similarly for 10, so one,

43
00:02:32,970 --> 00:02:34,500
two, three, four, five, six, seven, eight, nine, 10.

44
00:02:34,860 --> 00:02:38,470
So these are the biggest letters for all the elements.

45
00:02:39,030 --> 00:02:41,680
Now, initially, I am present at the current letter.

46
00:02:41,800 --> 00:02:44,770
OK, so initially I will be present at this letter.

47
00:02:45,120 --> 00:02:46,660
I am present at this letter.

48
00:02:47,610 --> 00:02:51,210
Now what I will do so I have to return the minimum number of items.

49
00:02:51,210 --> 00:02:51,570
Right.

50
00:02:51,570 --> 00:02:54,580
I have to minute number of jumps to reach the last index.

51
00:02:55,470 --> 00:02:56,150
Now let's see.

52
00:02:56,940 --> 00:02:58,260
So I am standing at one.

53
00:02:58,800 --> 00:03:01,920
OK, so I will traverse the current letter now.

54
00:03:01,920 --> 00:03:06,300
As soon as the current letter will finish, what I will do, I will jump to the biggest letter at this

55
00:03:06,300 --> 00:03:06,680
point.

56
00:03:07,020 --> 00:03:07,770
So jump.

57
00:03:08,430 --> 00:03:11,280
I am taking a jump to the biggest letter at this point.

58
00:03:11,580 --> 00:03:16,310
So at this point I have only one letter, OK, at this point I have only one letter.

59
00:03:16,320 --> 00:03:20,010
I do not have many options otherwise, but I will do I will choose the biggest letter.

60
00:03:20,370 --> 00:03:24,100
OK, so basically the idea is jus biggest letter.

61
00:03:25,320 --> 00:03:31,530
So at this point I have only this letter available to me, so I will take a jump to this letter.

62
00:03:32,100 --> 00:03:34,820
Then what I will do, I will traverse this letter.

63
00:03:34,980 --> 00:03:37,300
OK, but it was this letter.

64
00:03:37,560 --> 00:03:38,960
Now this letter has finished.

65
00:03:39,090 --> 00:03:41,430
So at this point, what is the biggest labor?

66
00:03:42,730 --> 00:03:45,010
So this is the biggest lead at this point.

67
00:03:45,130 --> 00:03:47,200
OK, so at this point.

68
00:03:49,340 --> 00:03:55,430
What ladies are available to us, so I have this letter available to me and I have this letter available

69
00:03:55,430 --> 00:03:59,270
to me, so I have to let those available to me at this point.

70
00:03:59,300 --> 00:04:03,960
OK, at this point, I have two letters available to me and I will choose the biggest letter.

71
00:04:04,640 --> 00:04:06,900
OK, so this is the bigger letter.

72
00:04:06,950 --> 00:04:08,430
OK, this is the bigger one.

73
00:04:09,140 --> 00:04:11,420
OK, so this is bigger than this.

74
00:04:12,700 --> 00:04:16,600
So I will make a jump to this letter and not this one.

75
00:04:17,260 --> 00:04:20,350
Now, finally, what I will do, I will reverse this later.

76
00:04:20,440 --> 00:04:24,870
OK, I will traverse this letter and I will be able to reach the last index.

77
00:04:25,390 --> 00:04:27,620
I will be able to reach the last index.

78
00:04:28,480 --> 00:04:29,810
Now, what will be my answer?

79
00:04:29,830 --> 00:04:33,840
The answer will be how many jumps I took so many times I took.

80
00:04:33,850 --> 00:04:38,890
So this is jump when this is the second jump.

81
00:04:39,220 --> 00:04:44,890
And obviously initially I was present at zero, so from zero to the current level.

82
00:04:44,890 --> 00:04:48,310
So I took three jumps, OK, I took three jumps.

83
00:04:49,660 --> 00:04:55,720
Now you can see yourself what will be the answer from when I will reach four from four, I will reach

84
00:04:55,720 --> 00:04:58,940
seven and from seven, I will be able to reach 10.

85
00:04:59,290 --> 00:05:00,760
OK, so this is jump one.

86
00:05:01,060 --> 00:05:02,070
This is jump, too.

87
00:05:02,080 --> 00:05:03,370
And this is jump three.

88
00:05:03,430 --> 00:05:04,870
OK, so my answer is correct.

89
00:05:05,880 --> 00:05:07,160
So our side is correct.

90
00:05:08,990 --> 00:05:12,410
OK, let's take one more example, let's take the example of.

91
00:05:13,450 --> 00:05:18,610
This one day did Corven, so do three one one four two three one one four.

92
00:05:21,180 --> 00:05:24,870
So two, then three, then one, then one and then four.

93
00:05:25,350 --> 00:05:29,310
So again, first of all, we will find out the biggest later for everyone.

94
00:05:29,380 --> 00:05:32,310
OK, so for two, what is the biggest lie that I will be able to reach?

95
00:05:32,340 --> 00:05:32,600
One.

96
00:05:32,970 --> 00:05:34,650
So from three, what is the biggest lie.

97
00:05:34,800 --> 00:05:36,840
So I will be able to reach for.

98
00:05:37,840 --> 00:05:43,410
For one, the biggest lie there is this one for one, this is the biggest letter and for the last six

99
00:05:43,420 --> 00:05:47,830
days only to find out the biggest letter, not initially, one jump.

100
00:05:48,810 --> 00:05:54,530
To go to the current leader, OK, then I will I the current leader now at this point.

101
00:05:55,650 --> 00:05:57,270
How many ladies available to me?

102
00:05:58,650 --> 00:06:04,140
So I have two ladies available to me, this one and this one, and obviously I will choose the biggest

103
00:06:04,140 --> 00:06:04,380
one.

104
00:06:04,590 --> 00:06:07,140
OK, so I will choose the bigger one.

105
00:06:07,530 --> 00:06:10,260
So I will take a jump to this later.

106
00:06:10,410 --> 00:06:14,510
And now I will traverse this ladder and I will be able to reach the last index.

107
00:06:14,730 --> 00:06:18,930
So how many times I took so I took the first jump and this is my second jump.

108
00:06:18,930 --> 00:06:20,200
So I took two jumps.

109
00:06:20,340 --> 00:06:22,540
So this is jump one from two to three.

110
00:06:22,590 --> 00:06:26,580
OK, so this is the first jump and this is the second jump.

111
00:06:26,970 --> 00:06:32,940
So I am taking two jumps and I'm traversing two letters since I'm traversing two ladders.

112
00:06:33,920 --> 00:06:36,090
I'm trying to listen to is my answer.

113
00:06:36,170 --> 00:06:38,850
OK, and the jump is also to say that approach is correct.

114
00:06:39,620 --> 00:06:42,860
Now, in the above example, you can see how many ladies we have traversed.

115
00:06:43,490 --> 00:06:45,440
So this is the first letter that we have.

116
00:06:45,480 --> 00:06:47,970
OK, so this is the first letter that we have produced.

117
00:06:48,080 --> 00:06:52,960
This is the second letter that we have traversed and this is the third letter that we have traversed.

118
00:06:52,970 --> 00:06:55,040
So in total, we try to three letters.

119
00:06:55,430 --> 00:06:56,840
So the output is three.

120
00:06:57,940 --> 00:07:00,160
OK, let's take one more example.

121
00:07:01,100 --> 00:07:04,140
Now, in this example, we will not be able to reach the last index.

122
00:07:04,190 --> 00:07:09,050
OK, so this is three, two, then one, then zero and then four.

123
00:07:09,320 --> 00:07:11,210
So what is the maximum indicator they can reach?

124
00:07:11,240 --> 00:07:14,380
So the biggest letter for three is basically to reach a zero.

125
00:07:14,720 --> 00:07:20,660
So four to I can reach zero for one, I can reach zero four zero.

126
00:07:20,670 --> 00:07:21,930
I can not reach anywhere.

127
00:07:22,190 --> 00:07:25,800
OK, so let us start reversing the first letter.

128
00:07:26,210 --> 00:07:29,150
OK, so I'm traversing the first letter.

129
00:07:30,610 --> 00:07:39,430
Now, at this point, no ladder is available, no ladder is available, since no lead is available and

130
00:07:39,430 --> 00:07:44,020
I am not present at the last or next, I am present at the second lesson because I am standing at the

131
00:07:44,020 --> 00:07:45,040
second largest index.

132
00:07:45,520 --> 00:07:48,030
So since there is no ladder available to us.

133
00:07:48,040 --> 00:07:50,140
So in this case I will return.

134
00:07:50,200 --> 00:07:51,120
Let's minus one.

135
00:07:51,170 --> 00:07:56,290
OK, our default answer minus one means I'm not able to reach the next sample.

136
00:07:56,440 --> 00:07:57,980
So I hope you understand the logic.

137
00:07:59,020 --> 00:08:00,580
Now let us write the code.

138
00:08:01,580 --> 00:08:03,770
So now let's ride the cold.

139
00:08:06,530 --> 00:08:08,520
So in the jump that Burnham's.

140
00:08:08,690 --> 00:08:11,900
OK, so let's change the name, the name is a.

141
00:08:13,070 --> 00:08:15,950
OK, so let us find out the size first.

142
00:08:16,160 --> 00:08:17,810
So this is a nazis'.

143
00:08:22,650 --> 00:08:25,730
So if the value of any is one, that means there is only one index.

144
00:08:25,740 --> 00:08:27,270
So how many jumps we need?

145
00:08:27,630 --> 00:08:29,420
So the first index is also the last index.

146
00:08:29,430 --> 00:08:30,330
So I need zero.

147
00:08:30,330 --> 00:08:30,690
James.

148
00:08:31,790 --> 00:08:32,630
Now, one more thing.

149
00:08:33,500 --> 00:08:36,049
So basically, if the first index zero.

150
00:08:37,510 --> 00:08:43,570
If I had the first index, zero zero percent, that means I cannot reach the last index, I cannot take

151
00:08:43,570 --> 00:08:45,580
any jump, so I return minus one.

152
00:08:49,130 --> 00:08:50,250
Now, what is the letter?

153
00:08:50,270 --> 00:08:55,940
So initially the letter is physical, OK, initially I am, but I will tell us the letter.

154
00:08:55,940 --> 00:08:56,300
Is it?

155
00:08:56,530 --> 00:08:59,150
OK, so what this letter will contain.

156
00:08:59,160 --> 00:09:02,030
So it will contain that letter, which I will provide.

157
00:09:02,180 --> 00:09:04,010
OK, so letter of zero.

158
00:09:04,910 --> 00:09:07,310
How many states are present in this letter?

159
00:09:09,870 --> 00:09:14,500
So how many states are represented in this letter, so if 06 are present in this letter?

160
00:09:14,590 --> 00:09:19,470
OK, and initially I have to initialize the jump variable to one, OK, not zero.

161
00:09:19,470 --> 00:09:20,160
It will be one.

162
00:09:20,230 --> 00:09:21,600
OK, you can see.

163
00:09:22,470 --> 00:09:25,020
So you can see.

164
00:09:25,050 --> 00:09:27,040
So this is the first to jump basically.

165
00:09:27,060 --> 00:09:29,800
OK, this is the first jump to jump to the first letter.

166
00:09:29,970 --> 00:09:32,350
So I have the initial I have the jump variable to one.

167
00:09:32,410 --> 00:09:34,530
OK, my answer will be present in the jump.

168
00:09:36,190 --> 00:09:37,090
So the jump is one.

169
00:09:38,900 --> 00:09:43,460
What is current, what is still so Steyr is basically my current leader.

170
00:09:47,890 --> 00:09:52,170
The state is basically the current leader and this leader variable, and it is the biggest leader,

171
00:09:52,840 --> 00:09:58,540
OK, the biggest leader or I can say the maximum eligible index.

172
00:09:59,860 --> 00:10:03,490
The maximum eligible index, so a jump is one.

173
00:10:05,500 --> 00:10:09,170
Now, let does iterate over the area, so I will start reading from one.

174
00:10:09,220 --> 00:10:11,620
OK, so I listen in and I placeless.

175
00:10:12,530 --> 00:10:19,380
Now, what we have to do, so check, so if the value of A is basically and minus one, that means I

176
00:10:19,380 --> 00:10:20,710
am present at the last index.

177
00:10:20,720 --> 00:10:24,030
So since I am placing it looks like inadvertently jumps.

178
00:10:24,590 --> 00:10:25,940
OK, I can return the jumps.

179
00:10:27,680 --> 00:10:37,000
Now you're standing at a and you're five plus elfy is greater than the maximum eligible index, if I

180
00:10:37,140 --> 00:10:42,960
a selfie is greater than the maximum reachable index, then you can update the maximum reachable index.

181
00:10:42,980 --> 00:10:46,310
OK, then I will update my maximum reachable index.

182
00:10:47,920 --> 00:10:48,670
Otherwise.

183
00:10:49,740 --> 00:10:56,520
So what I'm doing, I'm proposing the current leader, so I traversing the whole state minus minus what

184
00:10:56,520 --> 00:10:59,280
I am doing, I am proposing the current leader.

185
00:11:02,190 --> 00:11:05,760
So for travelling the country later, I have to do stator minus minus.

186
00:11:05,790 --> 00:11:06,110
OK.

187
00:11:11,040 --> 00:11:13,410
So I'm traversing to let them know if.

188
00:11:15,860 --> 00:11:18,150
The state becomes a zero.

189
00:11:18,860 --> 00:11:19,730
So what is the meaning?

190
00:11:19,760 --> 00:11:22,850
So if the state becomes zero, that means the current leader has been finished.

191
00:11:24,310 --> 00:11:25,120
OK, so.

192
00:11:26,050 --> 00:11:27,280
Currently, they're finished.

193
00:11:27,460 --> 00:11:29,320
That means I need to make a jump.

194
00:11:29,810 --> 00:11:32,440
OK, so I need to make a jump.

195
00:11:32,440 --> 00:11:32,830
Jump?

196
00:11:34,310 --> 00:11:43,100
Jampolis place, so you can see so if the current ladder finish, if the current ladder finishes, so

197
00:11:43,100 --> 00:11:44,580
at this point, the current ladder finish.

198
00:11:44,600 --> 00:11:46,190
So I need to take a jump.

199
00:11:46,190 --> 00:11:46,790
So that's why.

200
00:11:46,820 --> 00:11:47,280
Jump.

201
00:11:47,310 --> 00:11:47,960
Plus, plus.

202
00:11:48,380 --> 00:11:49,670
NetWare jump plus plus.

203
00:11:49,820 --> 00:11:51,430
And in the variable ladder.

204
00:11:52,280 --> 00:11:56,350
So what this little variable is containing it is containing the maximum Ridgewell index.

205
00:11:56,390 --> 00:11:57,740
So this does not exist.

206
00:11:57,980 --> 00:12:00,530
So here I told you to choose the biggest later.

207
00:12:00,740 --> 00:12:06,020
But how I am writing the code, I am writing the code in such a way that this letter does not exist.

208
00:12:06,350 --> 00:12:09,180
There is only one letter which is existing and this one letter.

209
00:12:09,200 --> 00:12:12,020
OK, there exists only one letter, which is this one.

210
00:12:13,300 --> 00:12:15,860
OK, you can see I'm updating the lighter variable.

211
00:12:16,010 --> 00:12:20,010
OK, so I'm only maintaining Voloder, I'm not maintaining many.

212
00:12:20,020 --> 00:12:22,570
Let us suppose you are present here.

213
00:12:22,970 --> 00:12:24,590
So I'm writing the code in such a way.

214
00:12:24,790 --> 00:12:25,480
So here.

215
00:12:26,790 --> 00:12:29,910
For the logical explanation, you can understand there are two leaders.

216
00:12:30,900 --> 00:12:34,080
But I am ready to going in such a way that the bigger lie that will exist.

217
00:12:34,500 --> 00:12:39,600
OK, so if this is the bigger, lighter, then only bigger will exist and the smaller one will not exist.

218
00:12:40,140 --> 00:12:44,610
So at this point, when you will take a jump, only this one letter will exist.

219
00:12:44,890 --> 00:12:46,480
OK, only this letter exists.

220
00:12:47,310 --> 00:12:52,960
So how many ideas I have to cover so I will subtract this from this.

221
00:12:53,250 --> 00:12:54,990
So this one is the current position.

222
00:12:56,450 --> 00:13:00,580
And this one is basically the mixing ritual index, so how many states will be there?

223
00:13:02,280 --> 00:13:05,160
So the current leader has been finished.

224
00:13:05,880 --> 00:13:07,630
You have to take a jump to the next leader.

225
00:13:07,650 --> 00:13:09,300
So that's why jump placeless.

226
00:13:10,330 --> 00:13:12,010
Now in the current leader.

227
00:13:13,010 --> 00:13:14,390
Now in the current leader.

228
00:13:16,580 --> 00:13:21,860
How many states have to cover some 72 index minus the current index, the index are to which I am standing.

229
00:13:22,560 --> 00:13:23,720
OK, simple one.

230
00:13:24,410 --> 00:13:26,990
Now, if the current level is negative.

231
00:13:28,660 --> 00:13:34,720
If the current leader is negative, that means I will not be able to reach the last Nixa written by

232
00:13:34,720 --> 00:13:37,440
Nelson or otherwise if this thing is not clear.

233
00:13:38,850 --> 00:13:41,370
What can I write here so you can write?

234
00:13:42,900 --> 00:13:52,460
So would you can ride so if the current index is basically denied equal to the maximum reachable index,

235
00:13:53,040 --> 00:13:58,200
if the current index is good, then all goes to make some reachable index, that means I will not be

236
00:13:58,200 --> 00:14:00,540
able to reach the last index or return minus one.

237
00:14:01,230 --> 00:14:02,280
OK, simple.

238
00:14:03,180 --> 00:14:05,550
And similarly, you can return minus one here.

239
00:14:05,890 --> 00:14:07,480
OK, you can return minus one here.

240
00:14:07,500 --> 00:14:08,970
So we are returning jumpier.

241
00:14:10,370 --> 00:14:13,880
OK, so this is the complete code, so what I'm doing here is.

242
00:14:15,100 --> 00:14:16,570
So I have this little variable.

243
00:14:17,660 --> 00:14:18,400
I have this.

244
00:14:18,950 --> 00:14:21,610
So let's take this example, two, three one one four.

245
00:14:21,670 --> 00:14:25,520
OK, so two, three, one, one and four.

246
00:14:26,300 --> 00:14:31,880
This is a zero one, two, three and four zero zero zero zero zero.

247
00:14:31,890 --> 00:14:33,650
So let me they make some ritual index.

248
00:14:33,660 --> 00:14:39,140
So initially they make some ritual indexes, basically index to and the jumps and the stair is basically

249
00:14:39,140 --> 00:14:40,010
to jump is one.

250
00:14:40,040 --> 00:14:41,480
OK, so take the jump.

251
00:14:42,450 --> 00:14:43,260
Jump is one.

252
00:14:44,570 --> 00:14:48,650
OK, Step decided to I'll get Tuesday's Venstre dustier.

253
00:14:49,660 --> 00:14:54,610
Now, I did so at three, the maximum level index becomes four.

254
00:14:55,210 --> 00:14:57,410
OK, I can reach the index four.

255
00:14:57,670 --> 00:14:59,780
So what I'm doing, I will update the ladder.

256
00:14:59,800 --> 00:15:00,940
So this is my letter.

257
00:15:02,930 --> 00:15:07,970
This is the biggest letter, so for one, the maximum literal index is basically this one.

258
00:15:08,420 --> 00:15:13,050
But what I will do, I will maintain only the bigger one, so I will not maintain this one.

259
00:15:13,250 --> 00:15:14,300
This one does not exist.

260
00:15:14,570 --> 00:15:17,030
Similarly, for one, this is the letter.

261
00:15:17,040 --> 00:15:20,120
But this letter is very small as compared to the Slagel.

262
00:15:20,120 --> 00:15:21,500
So this letter does not exist.

263
00:15:22,070 --> 00:15:24,670
So I have only to learn this one and this one.

264
00:15:25,220 --> 00:15:25,910
So what will do?

265
00:15:25,910 --> 00:15:27,080
I will try this letter.

266
00:15:27,530 --> 00:15:28,790
Then I will take a jump.

267
00:15:29,860 --> 00:15:31,270
And the jump will become, too.

268
00:15:31,300 --> 00:15:37,000
And finally, I will traverse this letter, the value of I will become minus one and then I will return

269
00:15:37,000 --> 00:15:37,460
the jump.

270
00:15:37,480 --> 00:15:40,770
So I will return to OK, I will return to surplus.

271
00:15:40,870 --> 00:15:41,440
My answer.

272
00:15:42,190 --> 00:15:43,650
So at this point, what happen?

273
00:15:43,960 --> 00:15:49,750
So at this point with a value so state is to then I will come here today minus minus two will become

274
00:15:49,750 --> 00:15:49,960
one.

275
00:15:49,960 --> 00:15:55,630
Then at this point state will become zero, so stay minus minus if the state becomes a zero.

276
00:15:55,870 --> 00:16:00,250
So at this point I do next to the state will become zero.

277
00:16:00,400 --> 00:16:01,750
Then you need to take a jump.

278
00:16:01,750 --> 00:16:04,330
I'm taking a jump then.

279
00:16:04,330 --> 00:16:06,750
But I am doing how many states I have to cover.

280
00:16:06,970 --> 00:16:08,650
So this is labor minus I.

281
00:16:09,040 --> 00:16:10,800
OK, so this is like the minus eight.

282
00:16:10,900 --> 00:16:12,780
The value of letter is basically next fall.

283
00:16:13,300 --> 00:16:17,890
So it makes four minus the current index which is two, so four minus two is basically two.

284
00:16:18,220 --> 00:16:19,810
So two is the value of the status.

285
00:16:20,380 --> 00:16:22,560
OK, you can see I have two.

286
00:16:22,690 --> 00:16:23,770
This is two.

287
00:16:23,850 --> 00:16:26,880
OK, so this distance, this distance is basically two.

288
00:16:27,820 --> 00:16:29,920
So that's why the value state is basically two.

289
00:16:30,460 --> 00:16:31,840
Then you will come here.

290
00:16:33,170 --> 00:16:38,180
The value state will become one, then you will come here and I equals N minus and you will return,

291
00:16:38,180 --> 00:16:43,010
jump and jump is basically to OK, so this is basically hard question.

292
00:16:43,040 --> 00:16:45,200
OK, I know it will be difficult to understand.

293
00:16:46,230 --> 00:16:50,190
But once you will go to the court, you will be able to understand it in a much better way.

294
00:16:50,400 --> 00:16:50,790
OK.

295
00:16:51,060 --> 00:16:56,130
And if you notice in the question says, we can always assume that we will be able to reach the last

296
00:16:56,130 --> 00:17:00,930
minute, but we have written code in such a way that you can see I am returning I am writing code in

297
00:17:00,930 --> 00:17:05,280
such a manner that if I am not able to easily lost and I will return minus one.

298
00:17:05,359 --> 00:17:07,520
OK, so you can remove this assumption.

299
00:17:07,530 --> 00:17:09,900
OK, we have written code in a good manner.

300
00:17:10,349 --> 00:17:12,390
Now let's have a court and then we will submit.

301
00:17:14,480 --> 00:17:18,560
Now, let's have it so what will with the time in the space complexity of our solution?

302
00:17:20,280 --> 00:17:26,579
So our goal is working fine, so the time, complexity of our solution is basically big golf and.

303
00:17:28,060 --> 00:17:31,730
And the space complexity, we are just creating only a few variables.

304
00:17:31,750 --> 00:17:32,900
So this is big often.

305
00:17:32,950 --> 00:17:35,770
OK, so this is finally the time and the space complexity.

306
00:17:36,310 --> 00:17:38,180
So this question is actually a hard one.

307
00:17:38,660 --> 00:17:41,260
OK, so it will take time for you to understand.

308
00:17:41,500 --> 00:17:45,400
So just go to the diagram and they will be able to understand it in a better way.

309
00:17:45,610 --> 00:17:47,420
So there are many ways to solve this question.

310
00:17:48,280 --> 00:17:50,970
OK, I think this one approach is better.

311
00:17:51,210 --> 00:17:53,190
This is a good way to understand the question.

312
00:17:54,490 --> 00:17:54,970
Thank you.

