1
00:00:01,480 --> 00:00:02,180
Hi, everyone.

2
00:00:02,200 --> 00:00:05,770
So in this video, we are going to solve this question find by Magnetation.

3
00:00:06,800 --> 00:00:12,170
OK, so basically the caution statement is very long, so since the statement is very long, we will

4
00:00:12,170 --> 00:00:13,630
read the question on the website only.

5
00:00:13,770 --> 00:00:18,920
OK, so in order to open the website, so basically this question, find permutation, this is present

6
00:00:19,070 --> 00:00:22,140
in private and this is also present unlettered.

7
00:00:22,220 --> 00:00:23,930
OK, but the problem.

8
00:00:26,520 --> 00:00:30,810
But the problem with the law today is basically the problem with this question is basically, if you

9
00:00:30,810 --> 00:00:36,330
will open the question so you can only open the question when you have premium subscription, OK, otherwise

10
00:00:36,330 --> 00:00:37,620
you cannot open the question.

11
00:00:37,710 --> 00:00:38,050
OK.

12
00:00:38,250 --> 00:00:39,980
They have only provided you the solution.

13
00:00:40,230 --> 00:00:43,510
So if you want to with the solution, they have provided three solutions.

14
00:00:43,530 --> 00:00:48,720
OK, using the hashtag using reversing the SABERA and the two pointer approach.

15
00:00:49,230 --> 00:00:51,940
So if you want to read the question, you can read it to herself.

16
00:00:52,280 --> 00:00:57,270
OK, we will solve this questionnaire in private, OK, because in the literature we need premium subscription

17
00:00:57,270 --> 00:00:59,820
to submit our answer and we don't have it.

18
00:00:59,850 --> 00:01:03,930
OK, so now let us solve the discussion and debate.

19
00:01:04,319 --> 00:01:06,120
So let us read the problem statement.

20
00:01:07,420 --> 00:01:09,410
So but the statement is quite simple.

21
00:01:09,490 --> 00:01:14,590
So what we have to do, so the input will basically be a string and the string will only content to

22
00:01:14,590 --> 00:01:16,300
let us later or later.

23
00:01:16,690 --> 00:01:19,980
OK, and we have a positive integer and as input.

24
00:01:20,020 --> 00:01:26,260
OK, so if you have two things as input string and a positive integer and contain only two letters,

25
00:01:26,260 --> 00:01:27,730
string will contain only two letters.

26
00:01:27,790 --> 00:01:28,340
Durai.

27
00:01:28,690 --> 00:01:30,260
OK, and what do you have to do?

28
00:01:30,490 --> 00:01:34,280
So we have to find any permutations of the first and positive integer.

29
00:01:34,480 --> 00:01:39,620
So that means I can only use basically one, two, three, four up to end.

30
00:01:39,780 --> 00:01:42,800
OK, we can only use this numbers.

31
00:01:42,850 --> 00:01:47,010
We can only use these numbers to find our reputation to generate our one rotation.

32
00:01:47,230 --> 00:01:49,440
We cannot use and plus one we cannot use.

33
00:01:49,450 --> 00:01:49,980
And plus two.

34
00:01:49,990 --> 00:01:52,060
OK, so these are wrong.

35
00:01:52,300 --> 00:01:53,710
We have to use this number.

36
00:01:54,910 --> 00:02:02,230
OK, how many numbers are there, so there are total numbers, so I have to generate a permutation so

37
00:02:02,230 --> 00:02:06,100
the size of the bottom rotation will be in OK, and what is the condition?

38
00:02:06,370 --> 00:02:07,660
So condition is basically.

39
00:02:07,690 --> 00:02:11,570
So if the character is dead, the next number will be smaller.

40
00:02:11,830 --> 00:02:15,490
So if the characters die, the next number will be smaller.

41
00:02:15,850 --> 00:02:21,370
If the character is basically a if the character is a, that means the next number will be greater.

42
00:02:21,440 --> 00:02:24,730
OK, so this is the condition for generating this permutation.

43
00:02:26,350 --> 00:02:28,870
OK, let us take an example to understand the question.

44
00:02:28,930 --> 00:02:31,560
OK, now the value of this basically three.

45
00:02:31,570 --> 00:02:35,050
So that means I can use three numbers one, two and three.

46
00:02:35,410 --> 00:02:37,720
OK, and this thing is basically 80.

47
00:02:37,930 --> 00:02:39,670
So the string is basically 80.

48
00:02:40,740 --> 00:02:44,090
So what is the meaning of so I the next number should be greater?

49
00:02:44,140 --> 00:02:45,360
OK, this is the output.

50
00:02:45,810 --> 00:02:49,310
So the output is basically one, three and two.

51
00:02:50,280 --> 00:02:53,700
So the meaning of AI is basically the next number should be greater.

52
00:02:53,730 --> 00:02:57,810
OK, so C1 three is good than when it is following this condition.

53
00:02:57,840 --> 00:03:00,180
OK, now the next character is the.

54
00:03:01,180 --> 00:03:02,830
So the next number should be smaller.

55
00:03:02,860 --> 00:03:05,180
So two is basically smaller than three.

56
00:03:05,200 --> 00:03:07,330
OK, the list basically smaller than three.

57
00:03:07,510 --> 00:03:09,130
So that's why this is the output.

58
00:03:09,160 --> 00:03:10,760
OK, this is the output.

59
00:03:10,780 --> 00:03:12,040
This is my permutation.

60
00:03:12,970 --> 00:03:17,120
OK, this is my permutation, very, very simple.

61
00:03:17,470 --> 00:03:23,280
So what we have to do, so basically the size of our reputation will be an OK size.

62
00:03:23,290 --> 00:03:25,660
Our reputation will be and is the given integer.

63
00:03:26,080 --> 00:03:27,940
We have to use each and every number.

64
00:03:28,090 --> 00:03:31,930
OK, I will use all the numbers starting from one to Dilan.

65
00:03:33,160 --> 00:03:39,250
Because I have to follow this condition next, unsimilar no condition, OK, and the stingray's is basically

66
00:03:39,260 --> 00:03:39,980
and minus one.

67
00:03:40,000 --> 00:03:41,740
OK, so if they atay.

68
00:03:42,100 --> 00:03:46,030
If I were on is basically of Sastry then the string is basically of size two.

69
00:03:46,480 --> 00:03:48,520
OK, let us take one more example.

70
00:03:48,690 --> 00:03:53,210
OK, now remember this thing and now we are taking example's or Dimmeys.

71
00:03:53,260 --> 00:03:54,430
Next time we should be smaller.

72
00:03:54,580 --> 00:03:56,300
I mean snick some should be greater.

73
00:03:56,360 --> 00:03:56,680
OK.

74
00:03:58,520 --> 00:04:03,230
So if the character is Dean Distin, the next number should be the next number should be smaller and

75
00:04:04,010 --> 00:04:05,810
for the next number should be greater.

76
00:04:05,890 --> 00:04:14,780
OK, now suppose if the string is basically I and and we will always be three, OK, and we will be

77
00:04:14,780 --> 00:04:15,890
one more plus one.

78
00:04:17,390 --> 00:04:20,720
OK, so the answer will be basically one, two and three.

79
00:04:21,829 --> 00:04:27,290
OK, so the meaning of is basically next number should be greater, so two is greater than one.

80
00:04:27,560 --> 00:04:30,500
Similarly, for a basically three is greater than two.

81
00:04:30,540 --> 00:04:32,690
OK, so this is the right permutation.

82
00:04:33,650 --> 00:04:35,500
OK, take one more example.

83
00:04:35,500 --> 00:04:40,880
So the value of this letter did and and is basically three, OK, obviously twilly plus one.

84
00:04:42,750 --> 00:04:44,820
Now, the answer will be basically two to one.

85
00:04:45,970 --> 00:04:51,370
So Damian's next number should be smaller, so considerately so please, basically smaller malignantly,

86
00:04:51,670 --> 00:04:54,280
similarly, one is basically smaller than two.

87
00:04:54,320 --> 00:04:56,290
OK, next number should be smaller.

88
00:04:57,760 --> 00:05:03,470
Now, let us take one more example, so the value of land is basically safe and lasting, let's say

89
00:05:03,470 --> 00:05:05,350
it is the I did.

90
00:05:06,450 --> 00:05:09,690
OK, so my output will be Fischman 42.

91
00:05:12,280 --> 00:05:18,760
OK, so Demi's next number should be smaller, so one is smaller than five, correct?

92
00:05:19,180 --> 00:05:21,040
Amy's next number should be greater.

93
00:05:21,340 --> 00:05:23,970
So basically, Ford is greater than one correct answer.

94
00:05:24,610 --> 00:05:27,070
B should be next number should be smaller.

95
00:05:27,070 --> 00:05:29,590
So threes smaller than four, correct answer.

96
00:05:29,830 --> 00:05:31,070
Next number should be smaller.

97
00:05:31,090 --> 00:05:33,040
So two is basically smaller than three.

98
00:05:33,040 --> 00:05:33,890
So correct answer.

99
00:05:33,910 --> 00:05:39,430
OK, and it's five means I have to use all the numbers starting from one till five.

100
00:05:39,470 --> 00:05:41,310
OK, I have to use all the numbers.

101
00:05:41,320 --> 00:05:43,270
So in total I have to use five numbers.

102
00:05:43,600 --> 00:05:45,640
That's why the size of the ad is basically five.

103
00:05:45,670 --> 00:05:47,680
Similarly, I have to use three numbers.

104
00:05:47,680 --> 00:05:48,320
One, two, three.

105
00:05:48,340 --> 00:05:49,840
That's why the size of that is three.

106
00:05:50,510 --> 00:05:51,700
I have to use three numbers.

107
00:05:51,730 --> 00:05:53,500
That's why the size of the ad is basically three.

108
00:05:53,740 --> 00:05:56,800
OK, so I hope by now you have understood the question.

109
00:05:56,890 --> 00:06:04,680
OK, so the input will basically be a string, a number and the string will contain only two characters,

110
00:06:04,840 --> 00:06:06,160
DNA testing.

111
00:06:06,230 --> 00:06:07,960
We can only these two type of characters.

112
00:06:08,710 --> 00:06:14,890
The next number should be smaller in Japan rotation and I mean the next number should be greater.

113
00:06:15,110 --> 00:06:17,200
OK, and these are some examples.

114
00:06:17,560 --> 00:06:19,720
Now let us discuss how we control discussion.

115
00:06:19,960 --> 00:06:23,020
OK, so basically what is the meaning of a.

116
00:06:27,450 --> 00:06:33,360
So what is the meaning of a suicide note, the next number should be larger.

117
00:06:33,420 --> 00:06:37,230
OK, so what we will do, we will put the smallest element.

118
00:06:37,260 --> 00:06:39,350
OK, so what I'm trying to say.

119
00:06:39,360 --> 00:06:40,800
So this is my said.

120
00:06:42,430 --> 00:06:49,630
This is my third, it is containing one, two, three elements, I have to use each and every element.

121
00:06:49,670 --> 00:06:51,790
OK, I have to use each and every element.

122
00:06:52,030 --> 00:06:57,130
So the meaning of eye is basically the next number should be the next number should be larger.

123
00:06:57,190 --> 00:07:03,640
OK, so what I am trying to say here is whenever you see a whenever we will see what we will do.

124
00:07:04,270 --> 00:07:10,510
So basically we will substitute the smallest remaining number from the set, OK, corresponding to the

125
00:07:10,510 --> 00:07:14,560
eye, OK, as it automatically makes the next element to be larger.

126
00:07:14,800 --> 00:07:15,820
I am repeating myself.

127
00:07:16,360 --> 00:07:22,720
So whenever you will encounter I, our aim is basically to make the next number greater.

128
00:07:22,750 --> 00:07:28,690
So what we will do, we will put the smallest element, we will select the smallest element and we will

129
00:07:29,200 --> 00:07:34,900
put it in the place of a small take smallest element and put it in place of a.

130
00:07:36,120 --> 00:07:41,800
Similarly, whenever you have basically been so diminished, the next number should be smaller.

131
00:07:42,270 --> 00:07:48,150
So what I will do, I will select the largest element, I will select the largest element, and I will

132
00:07:48,150 --> 00:07:49,800
put it in the place of the.

133
00:07:50,850 --> 00:07:54,390
Now, let's take an example, so this example only.

134
00:07:55,680 --> 00:08:02,040
OK, so our logic is very simple, so if you are encountering the that means put the largest element,

135
00:08:02,310 --> 00:08:03,630
put not largest element.

136
00:08:04,630 --> 00:08:07,180
If you encounter I, that means put.

137
00:08:08,370 --> 00:08:09,480
The smallest element.

138
00:08:11,030 --> 00:08:14,920
If I will put the smallest element, the next element will always be a larger element.

139
00:08:15,080 --> 00:08:20,050
If I put the largest element, then the next element will always be the smaller element.

140
00:08:20,090 --> 00:08:20,450
OK.

141
00:08:21,920 --> 00:08:29,090
I'm repeating myself, this is basically the main idea is the main idea, if you encountered where do

142
00:08:29,090 --> 00:08:31,130
we look, we will put the largest element.

143
00:08:32,200 --> 00:08:37,000
From our side, so that will automatically make the next number smaller.

144
00:08:38,090 --> 00:08:43,400
OK, if I will put the largest element from the side, then it automatically means the next number will

145
00:08:43,400 --> 00:08:45,170
be smaller, so our condition is met.

146
00:08:45,680 --> 00:08:49,120
Similarly, if I encounter, I will put the smallest element.

147
00:08:49,430 --> 00:08:52,790
So the next element will always be the larger element.

148
00:08:53,900 --> 00:08:54,920
You can see yourself.

149
00:08:57,280 --> 00:09:00,050
Whenever you encounter, the next element should be smaller.

150
00:09:00,550 --> 00:09:02,650
OK, next element should be smaller.

151
00:09:02,800 --> 00:09:06,190
So for making the next element smaller, I will put the largest element here.

152
00:09:06,400 --> 00:09:11,520
Similarly, if I encountered what I will do, I have to make the next element larger.

153
00:09:11,530 --> 00:09:16,410
So for making the next element larger, I will put the smallest element simple.

154
00:09:17,320 --> 00:09:19,650
Now let's take an example so we can understand.

155
00:09:19,660 --> 00:09:24,280
OK, so let us take this example, DADT and our answer is five.

156
00:09:24,280 --> 00:09:25,130
One, four, three, two.

157
00:09:25,190 --> 00:09:25,510
OK.

158
00:09:28,070 --> 00:09:35,960
So basically estranges be a the the what are our elemental our elements are one, two, three, four

159
00:09:35,960 --> 00:09:36,440
and five.

160
00:09:37,850 --> 00:09:38,270
OK.

161
00:09:39,670 --> 00:09:45,940
Now, it look, we will take two point us, so let's call it basically start, let's call it and.

162
00:09:47,040 --> 00:09:47,460
OK.

163
00:09:48,380 --> 00:09:51,860
Now, our logic is so our logic was Dimmeys put.

164
00:09:53,650 --> 00:10:00,420
Largest element, because I have to make this next element smaller and I put the smallest element.

165
00:10:00,460 --> 00:10:04,390
OK, this is a I mean, the smallest element.

166
00:10:04,390 --> 00:10:05,400
So this was the condition.

167
00:10:05,470 --> 00:10:08,280
This means I have to make the next number smaller.

168
00:10:08,770 --> 00:10:11,950
It means I have to make the next to no greater.

169
00:10:14,290 --> 00:10:16,420
So for making this condition, I have to do this.

170
00:10:19,760 --> 00:10:24,020
OK, so demons, pathologist, largest armies, but smallest.

171
00:10:25,470 --> 00:10:31,380
So be what is the meaning of the fourth largest logistics, basically five, OK, so this is basically

172
00:10:31,380 --> 00:10:31,800
sorted.

173
00:10:32,310 --> 00:10:33,180
This is sorted.

174
00:10:34,460 --> 00:10:35,300
So put five.

175
00:10:37,080 --> 00:10:38,090
I mean, sportsmen.

176
00:10:38,430 --> 00:10:42,540
So when is the smallest, so after putting five, but I will do, I will do and minus minus.

177
00:10:43,750 --> 00:10:50,110
Now I miss, but smallest, so smallest is basically the start, so I will put one and I will do start

178
00:10:50,110 --> 00:10:50,710
placeless.

179
00:10:52,640 --> 00:10:58,040
The spotlight, just so this is the largest support, largest land mine, this mine, this.

180
00:10:59,900 --> 00:11:05,540
Again, the diminished but largest, OK, but largest, so I will put three and I will do any minus

181
00:11:05,540 --> 00:11:09,920
minus support three and finally I will become.

182
00:11:10,280 --> 00:11:13,940
But there is one element in our side, so I will write to also.

183
00:11:13,970 --> 00:11:15,480
OK, so this is my answer.

184
00:11:15,500 --> 00:11:16,910
Five, four, five.

185
00:11:16,910 --> 00:11:17,730
One, four, three, two.

186
00:11:17,780 --> 00:11:19,030
OK, five, 142.

187
00:11:19,490 --> 00:11:21,140
And you can see our answer is correct.

188
00:11:21,140 --> 00:11:22,340
Five, one, four, three, two.

189
00:11:22,590 --> 00:11:24,670
OK, let's take some more examples.

190
00:11:27,100 --> 00:11:33,610
Just remember this condition and now let us take somewhat example, remember this condition, so this

191
00:11:33,640 --> 00:11:38,640
is basically let's call it idee, OK, so the value of N will be three.

192
00:11:39,040 --> 00:11:40,120
So this is one.

193
00:11:40,420 --> 00:11:40,960
This is two.

194
00:11:40,960 --> 00:11:41,650
And this is three.

195
00:11:42,220 --> 00:11:43,210
This is my start.

196
00:11:43,400 --> 00:11:44,290
This is my end.

197
00:11:45,500 --> 00:11:49,480
OK, so I means put smallest.

198
00:11:49,540 --> 00:11:50,320
So put one.

199
00:11:51,830 --> 00:11:58,850
But start a head start, plus the spotlight, just logistics to support three and two and a minus minus.

200
00:11:59,570 --> 00:12:05,520
And finally, I will end and we have one character left, so I will do so for this input variety.

201
00:12:05,540 --> 00:12:06,320
This is my answer.

202
00:12:06,320 --> 00:12:06,860
One, three, two.

203
00:12:08,710 --> 00:12:14,440
OK, let's take one more example, this thing is basically I'm OK, and I have one, two, three.

204
00:12:15,960 --> 00:12:22,070
So I mean, sports analyst, so I mean, sports analyst, when this smallest again, I mean sportsman

205
00:12:22,080 --> 00:12:24,550
is to report to and thing will end.

206
00:12:24,730 --> 00:12:26,670
So I the remaining element is this.

207
00:12:26,670 --> 00:12:28,360
So I will put this is my answer.

208
00:12:28,740 --> 00:12:30,030
Let's take one more example.

209
00:12:30,030 --> 00:12:30,720
ESPN's duty.

210
00:12:31,320 --> 00:12:35,070
OK, and my this is my favorite part of this is start.

211
00:12:35,080 --> 00:12:35,670
This is end.

212
00:12:36,000 --> 00:12:36,990
So be me sport.

213
00:12:36,990 --> 00:12:43,780
Largest city's largest redeeming sport, largest city's largest, Portree, again, the largest BU's

214
00:12:43,800 --> 00:12:49,920
largest, because I will do end minus minus supporta, then I will do N minus MINURSO and will come

215
00:12:49,920 --> 00:12:51,830
here and finally this thing will end.

216
00:12:51,840 --> 00:12:54,480
I have one element left, so I will right that one element.

217
00:12:54,490 --> 00:12:55,290
So this is my answer.

218
00:12:55,300 --> 00:12:55,920
Two to one.

219
00:12:57,180 --> 00:12:58,380
OK, understood.

220
00:12:59,510 --> 00:13:01,100
I'm repeating myself, what is the logic?

221
00:13:01,130 --> 00:13:02,090
So this is the question.

222
00:13:03,360 --> 00:13:05,380
Demeans the next element should be smaller.

223
00:13:05,610 --> 00:13:10,830
And what I'm saying here is if you encounter the largest element because it will put the largest element,

224
00:13:11,130 --> 00:13:13,260
the next element will automatically be smaller.

225
00:13:13,920 --> 00:13:16,710
Similarly, I miss the next element should be greater.

226
00:13:17,040 --> 00:13:21,570
And here I'm saying I support the smallest element because it will put the smallest element.

227
00:13:21,780 --> 00:13:23,800
Then the next element will always be greater.

228
00:13:24,180 --> 00:13:25,230
OK, simple.

229
00:13:25,620 --> 00:13:27,120
So this is to point that approach.

230
00:13:28,160 --> 00:13:33,860
I will take 2.5 start points and end point that, OK, now let's write the code.

231
00:13:36,420 --> 00:13:38,590
So we will ride the coat on in private.

232
00:13:38,610 --> 00:13:39,000
OK?

233
00:13:39,210 --> 00:13:43,350
I already told you we would like to go it because this question is not present only to.

234
00:13:47,540 --> 00:13:48,860
So in order to write the code.

235
00:13:52,480 --> 00:13:54,280
So basically, we have to return the property.

236
00:13:54,310 --> 00:13:56,110
Yes, OK, we do not have to print something.

237
00:13:56,410 --> 00:14:00,640
We have to return Retrophin pages and put basically string and a number and.

238
00:14:00,720 --> 00:14:07,510
OK, so since we have to return the property, just let us make a vector of integers, OK?

239
00:14:07,510 --> 00:14:08,590
Let's call it answer.

240
00:14:09,220 --> 00:14:13,930
So it will be an OK it says will be in no time to do.

241
00:14:13,930 --> 00:14:17,770
I have to take two point start point at any point as a start point there will be one.

242
00:14:19,660 --> 00:14:21,530
And there will be in OK.

243
00:14:21,610 --> 00:14:25,960
And if the largest element now we have to do I have to get rid of this thing.

244
00:14:26,040 --> 00:14:29,220
OK, so now let us rid of the strings.

245
00:14:29,220 --> 00:14:32,140
So Y equals zero I and astrocyte.

246
00:14:39,770 --> 00:14:43,250
No simple conditions or if I will encounter.

247
00:14:45,810 --> 00:14:47,910
So if the given character is the.

248
00:14:50,110 --> 00:14:52,990
So if the government exposed what I have to do.

249
00:14:55,460 --> 00:14:58,270
So I have to put the largest element that means end point.

250
00:14:58,490 --> 00:15:01,940
OK, so what I will do instead of a.

251
00:15:05,300 --> 00:15:06,720
So this is basically end.

252
00:15:06,740 --> 00:15:09,800
OK, I have to put the largest element, then I will do.

253
00:15:09,800 --> 00:15:10,310
And my niece.

254
00:15:10,310 --> 00:15:10,730
My niece.

255
00:15:12,260 --> 00:15:15,290
In the Elzbieta you can write, I will start.

256
00:15:16,730 --> 00:15:24,120
So I will start I will start placeless, simple, finally after what I have to do.

257
00:15:24,150 --> 00:15:28,820
So one element will be left, OK, you can see carefully there's always one element left.

258
00:15:29,120 --> 00:15:30,630
There's always one element left.

259
00:15:30,650 --> 00:15:34,280
The last one element, OK, so the last element will be left.

260
00:15:34,790 --> 00:15:42,260
So instead of lasting Nix's and minus one, OK, you can write start or you can also write and they

261
00:15:42,260 --> 00:15:45,240
both are saying, OK, you can write a starter and they both are the same.

262
00:15:45,960 --> 00:15:48,530
Finally, our answer is so we can return our answer.

263
00:15:48,590 --> 00:15:49,480
OK, simple.

264
00:15:49,520 --> 00:15:52,970
This is the computer knowledge testable code and then we will submit.

265
00:15:58,750 --> 00:16:00,430
OK, so there's some mistake here.

266
00:16:05,900 --> 00:16:11,190
OK, so the mistake is basically the name of the string is S and I'm creating S here also.

267
00:16:11,210 --> 00:16:12,410
So let's make it start.

268
00:16:13,840 --> 00:16:15,970
OK, so what I will do.

269
00:16:17,740 --> 00:16:22,960
I will ride here and similarly, this is a start, plus, plus.

270
00:16:25,230 --> 00:16:29,820
This is basically start OK now I think it'll work fine.

271
00:16:29,880 --> 00:16:30,900
OK, let's test.

272
00:16:36,740 --> 00:16:38,600
OK, so I forgot to add semicolon.

273
00:16:38,630 --> 00:16:42,260
OK, so semicolon, some completion error.

274
00:16:50,500 --> 00:16:51,820
OK, so now let's summered.

275
00:16:58,220 --> 00:16:59,840
OK, so our goal is working fine.

276
00:17:00,140 --> 00:17:03,770
OK, now let's discuss the time and the space complexity.

277
00:17:04,040 --> 00:17:09,040
So basically the time complexity is big often, OK, what we are doing, we are using to point that

278
00:17:09,050 --> 00:17:09,460
approach.

279
00:17:09,770 --> 00:17:13,130
I have a start point there and similarly, I have an end point there.

280
00:17:13,210 --> 00:17:19,849
OK, so we are just getting on with the string and the string sizes basically and minus one, OK, this

281
00:17:20,030 --> 00:17:21,829
size is basically and minus one to the time.

282
00:17:21,829 --> 00:17:25,510
Complexity is big often and the space complexities big of one.

283
00:17:25,680 --> 00:17:26,060
OK.

284
00:17:27,270 --> 00:17:32,430
The code is very simple, if you will encounter the word doing, but the largest element.

285
00:17:33,430 --> 00:17:39,880
Because if it will put the largest element, the next element will always be the smaller element, which

286
00:17:39,880 --> 00:17:40,640
is the requirement.

287
00:17:40,840 --> 00:17:46,780
Similarly, if you will encounter a you will put the smallest element because it will put the smallest

288
00:17:46,780 --> 00:17:50,860
element that will automatically makes the next element a larger element.

289
00:17:51,130 --> 00:17:52,510
And that is the requirement.

290
00:17:52,540 --> 00:17:54,520
OK, so requirement is fulfilled.

291
00:17:54,550 --> 00:18:00,100
Finally, we can take an example and we can understand there is always one element left which is not

292
00:18:00,100 --> 00:18:02,380
pushed inside the answer vector.

293
00:18:02,530 --> 00:18:05,950
This is the director and the last index is basically and minus one.

294
00:18:05,960 --> 00:18:09,000
So you can write start or you can also write and hear.

295
00:18:09,040 --> 00:18:11,020
OK, and then I'm returning my answer.

296
00:18:12,020 --> 00:18:16,550
OK, so this question was basically asked in the Google telephonic interview.

297
00:18:16,580 --> 00:18:16,860
OK.

298
00:18:16,880 --> 00:18:21,740
So when I gave the interview for Google, they asked me this question in their telephonic round.

299
00:18:21,950 --> 00:18:25,640
OK, so if you have any doubt in this question, you can ask me.

300
00:18:25,640 --> 00:18:26,300
OK, thank you.

