1
00:00:01,770 --> 00:00:02,350
Hi everyone.

2
00:00:02,350 --> 00:00:06,630
So in this lesson we are going to solve this question remove duplicates in entity.

3
00:00:06,700 --> 00:00:08,350
So consider this example.

4
00:00:08,350 --> 00:00:10,870
So this is basically alien Deja ready.

5
00:00:10,930 --> 00:00:17,140
And what we have to do so basically we have to write down a vector of integers and in this vector often

6
00:00:17,140 --> 00:00:17,940
digits.

7
00:00:17,990 --> 00:00:19,900
So consider this is the vector.

8
00:00:19,900 --> 00:00:25,930
So in this vector often teachers element will appear only once they will be all unique elements inside

9
00:00:25,960 --> 00:00:26,890
this vector.

10
00:00:26,890 --> 00:00:35,110
So let me show you what I would put one push ahead then two then three then two is coming again.

11
00:00:35,120 --> 00:00:39,270
So two is already present inside the red pencil will not take two then one.

12
00:00:39,290 --> 00:00:40,550
So one is already present.

13
00:00:40,550 --> 00:00:44,480
Take five you're going to take four.

14
00:00:44,580 --> 00:00:49,720
You can not take one because one is already present and you cannot take three because he's already present.

15
00:00:49,800 --> 00:00:51,210
So this will be my output.

16
00:00:51,250 --> 00:00:54,740
Okay so one two three five and four.

17
00:00:54,750 --> 00:00:55,910
So if you will notice.

18
00:00:55,920 --> 00:01:03,220
So this vector is basically containing all unique elements so that is the meaning of removing duplicates.

19
00:01:03,250 --> 00:01:04,950
So in this added obligates at present.

20
00:01:04,960 --> 00:01:08,180
But if will see the vector all elements are unique elements.

21
00:01:08,380 --> 00:01:13,890
And one more thing to notice elements that are appearing in the same order might seem or that I mean.

22
00:01:14,110 --> 00:01:17,130
So one is coming before two in the original also.

23
00:01:17,160 --> 00:01:23,620
So one was before two similarly five is coming before forward because in the original Eddy five was

24
00:01:23,620 --> 00:01:24,800
coming before four.

25
00:01:24,850 --> 00:01:27,350
So that is the meaning of the same order.

26
00:01:27,370 --> 00:01:28,140
So what we have to do.

27
00:01:28,140 --> 00:01:32,360
So given this integer Eddie we have to find this vector.

28
00:01:32,360 --> 00:01:38,930
We have to generate this vector that will contain all the unique elements and in the same order.

29
00:01:38,960 --> 00:01:41,230
Now let's see how we can solve this question.

30
00:01:41,270 --> 00:01:43,430
So when we were solving this question is very simple.

31
00:01:43,430 --> 00:01:44,560
So what do we do.

32
00:01:44,570 --> 00:01:48,950
You pick one element and then you will search whether this element this peasant vector or not if it

33
00:01:48,950 --> 00:01:54,390
is not present then you will push similarly the second element check it is present inside the vector

34
00:01:54,410 --> 00:01:58,020
not if it is not present then you can push otherwise do not push.

35
00:01:58,370 --> 00:02:03,830
Similarly the third element and then I did or the vector and check whether this president does not present.

36
00:02:03,830 --> 00:02:06,770
So in this we will be able to solve this question.

37
00:02:06,800 --> 00:02:10,640
Now where did the time complexity if we will use this approach.

38
00:02:10,640 --> 00:02:15,850
So so this is my DNA the input.

39
00:02:15,850 --> 00:02:19,740
So this is an very and if you will follow the above approach.

40
00:02:19,750 --> 00:02:23,340
So whatever time complexity so this is my vector.

41
00:02:23,350 --> 00:02:25,700
So if you view the vectors containing zero elements.

42
00:02:25,840 --> 00:02:30,380
So you pick the first element you will check that base and pretty so you can push this element.

43
00:02:30,490 --> 00:02:33,400
So one bug has been no big.

44
00:02:33,400 --> 00:02:38,170
The second element so you will activate all the vector to check whether this element is present or not.

45
00:02:38,170 --> 00:02:43,900
So basically the amount of Ogden then similarly you will pick the third element so you will hydrate

46
00:02:43,920 --> 00:02:46,410
or whatever triple check it is present or not.

47
00:02:46,410 --> 00:02:48,070
Similarly for the net element.

48
00:02:48,070 --> 00:02:54,610
So for the entertainment what we have to do you have to hydrate or the compute the vector to check whether

49
00:02:54,610 --> 00:02:56,530
the element is present or not.

50
00:02:56,530 --> 00:03:01,720
So invoke you have to perform and work because you have to edit it or the compute vector to check whether

51
00:03:01,720 --> 00:03:03,570
this element is present or not.

52
00:03:03,580 --> 00:03:05,050
So what is the time complexity.

53
00:03:05,060 --> 00:03:13,890
So if you will add all this so N plus and minus one plus and minus two it will go on till 1 and we know

54
00:03:13,890 --> 00:03:13,970
it.

55
00:03:13,970 --> 00:03:17,620
So this is basically off and square and big off and square.

56
00:03:17,750 --> 00:03:22,280
So time complexities big golf and square.

57
00:03:22,360 --> 00:03:25,460
Now how can we optimize our time complexity.

58
00:03:25,500 --> 00:03:31,020
So basically what we are doing we are picking one element and then we are searching over the compute

59
00:03:31,020 --> 00:03:34,110
vector to check whether the element is present or not.

60
00:03:34,110 --> 00:03:39,950
So if we can perform the searching in constant time if we can't perform this searching in constant time

61
00:03:39,980 --> 00:03:42,150
then our time complexity will become.

62
00:03:42,320 --> 00:03:47,560
So picking every element and then checking whether it is present or not so and multiply when.

63
00:03:47,570 --> 00:03:53,570
So that means that time complexity will become linear if we can do the searching in the vector in constant

64
00:03:53,570 --> 00:03:54,440
time.

65
00:03:54,470 --> 00:04:00,050
So here what is the time complexity so you are picking each and every element and then you have to search

66
00:04:00,110 --> 00:04:02,060
inside the vector so n multiply.

67
00:04:02,070 --> 00:04:06,530
And so this is for picking every element and this is for searching inside the vector.

68
00:04:06,980 --> 00:04:14,180
But I am saying if we can perform the search in constant time so their time complexity will become Linear

69
00:04:15,030 --> 00:04:18,690
B golf in and how we can check in constant time.

70
00:04:18,800 --> 00:04:20,000
Basically we can use.

71
00:04:20,000 --> 00:04:25,970
We can take the help of the map because in map searching is constant time insert delete search all three

72
00:04:25,970 --> 00:04:35,200
operations are constant in and on the map if you will use the map then insert delete search all your

73
00:04:35,210 --> 00:04:36,540
patients will take log time.

74
00:04:36,800 --> 00:04:41,000
So in this question where do we lose we will use on a road map.

75
00:04:41,240 --> 00:04:43,850
Now many people can see why use our road map.

76
00:04:43,850 --> 00:04:46,020
We can also sort discussion with the help of Eddie.

77
00:04:46,760 --> 00:04:49,000
So how against all this question with the help of Eddie.

78
00:04:49,070 --> 00:04:51,890
So consider this example only.

79
00:04:52,060 --> 00:04:53,160
So what do you do.

80
00:04:53,230 --> 00:04:54,640
You will find out the maxim element.

81
00:04:54,670 --> 00:04:59,280
So five is the maxim element and now what do do after find out the maximum element.

82
00:04:59,290 --> 00:05:05,020
You will make an array of size five plus one so five is the maximum element to make an area of size

83
00:05:05,020 --> 00:05:05,940
five plus one.

84
00:05:06,070 --> 00:05:08,700
So the size of that it will be five six.

85
00:05:08,800 --> 00:05:10,450
This is five and this is zero.

86
00:05:11,140 --> 00:05:13,180
And basically this it will be a billionaire.

87
00:05:13,180 --> 00:05:14,470
True False Eddie.

88
00:05:14,560 --> 00:05:15,860
Now what do you do.

89
00:05:15,910 --> 00:05:17,580
You will check when this present.

90
00:05:17,680 --> 00:05:22,040
So inside one initially this ad it will be initialized with false.

91
00:05:22,060 --> 00:05:23,830
So I will check one go to one.

92
00:05:23,860 --> 00:05:24,750
It is false.

93
00:05:24,790 --> 00:05:29,740
So basically you can push it inside the vector and make it through know if the next time one will come

94
00:05:29,920 --> 00:05:30,680
you will see here.

95
00:05:30,700 --> 00:05:32,580
You will check or when is true.

96
00:05:32,590 --> 00:05:34,530
So do not push inside the vector.

97
00:05:34,630 --> 00:05:37,630
So definitely you can use this approach.

98
00:05:37,660 --> 00:05:40,810
Let's take one more example for example three so will check.

99
00:05:40,840 --> 00:05:41,880
You will go to three.

100
00:05:41,890 --> 00:05:45,130
So initially this billion that is initialized with force you will check.

101
00:05:45,310 --> 00:05:46,290
Oh please false.

102
00:05:46,300 --> 00:05:51,490
So you will push three but the next time t will appear and we will also make it through.

103
00:05:51,550 --> 00:05:52,530
We will also make it true.

104
00:05:52,540 --> 00:05:54,630
After pushing inside the vector we will make it through.

105
00:05:54,640 --> 00:05:58,930
So when the next time ts are coming you will go to index three and you will check.

106
00:05:58,930 --> 00:06:00,270
No trees true.

107
00:06:00,310 --> 00:06:05,080
So basically you will not push inside the vector again so we can definitely use this approach.

108
00:06:05,080 --> 00:06:11,690
We can definitely take the help of Belinelli but the problem is consider you are a clause that your

109
00:06:11,730 --> 00:06:19,060
input error is basically of this size it is containing elements of this type then then turned to poetry

110
00:06:19,140 --> 00:06:23,250
then then to power six then then two power seven and so on.

111
00:06:23,260 --> 00:06:29,000
So what do you have to do if you really follow this approach what is the maximum element so 10 to the

112
00:06:29,000 --> 00:06:33,980
power 7 is the maximum element and obviously the elements that are beating so tend to power to you then

113
00:06:33,980 --> 00:06:36,670
tend to power sticks then again tend to power seven.

114
00:06:36,670 --> 00:06:38,660
Obviously there are duplicates.

115
00:06:38,660 --> 00:06:42,110
Now in order to do so I'll just caution using this method.

116
00:06:42,110 --> 00:06:43,580
This is the maximum element.

117
00:06:43,580 --> 00:06:49,000
So basically the size of the added the boolean that it will be of the size ten to power seven plus one.

118
00:06:49,040 --> 00:06:50,720
So this will be your Belinelli.

119
00:06:50,720 --> 00:06:55,790
Now this is very huge space very very huge huge space.

120
00:06:56,690 --> 00:06:58,970
Okay so this is wrong.

121
00:06:58,970 --> 00:07:00,100
Now one more thing.

122
00:07:00,530 --> 00:07:01,770
The elements can be negative.

123
00:07:01,770 --> 00:07:06,430
Also Indonesia can be negative so I can have minus 10.

124
00:07:06,640 --> 00:07:12,990
So how can you store in minus 10 here minus 10 index does not exist minus 10 in next will not exist.

125
00:07:13,030 --> 00:07:16,810
So that means this approach has a lot of limitations.

126
00:07:17,050 --> 00:07:22,090
If that is basically of if that is containing elements of these types and also if that is containing

127
00:07:22,090 --> 00:07:25,180
negative elements then you cannot use this approach.

128
00:07:25,900 --> 00:07:29,170
So basically we have to use map in this case.

129
00:07:29,170 --> 00:07:32,520
Now if you are using map you can definitely do something like this.

130
00:07:32,710 --> 00:07:36,300
My map of minus 5 is true.

131
00:07:36,400 --> 00:07:43,620
You can definitely do something like this similarly you can do my map off tend to power 7 is true.

132
00:07:43,710 --> 00:07:49,890
No my map of 10 about 7 desert means that your map is often 2 power seven cities.

133
00:07:50,080 --> 00:07:55,030
We will see the implementation so map will take very very small space.

134
00:07:55,170 --> 00:08:00,850
Map will take very very small space so 10 12 7 doesn't mean the size of the map will return to power

135
00:08:00,850 --> 00:08:05,560
so no it will be very very loose very very loose as compared to that is.

136
00:08:06,250 --> 00:08:07,370
And one more thing.

137
00:08:07,390 --> 00:08:09,610
So this is in digit Eddie.

138
00:08:09,910 --> 00:08:13,100
So we are talking about in digit Eddie now in the ocean.

139
00:08:13,120 --> 00:08:20,400
If there was correct that Eddie if there was correct bet if for example if there was characters like

140
00:08:20,460 --> 00:08:24,080
it then c c then the B.

141
00:08:24,090 --> 00:08:28,800
So if instead of think digit edit correct that it was given then definitely what you can do.

142
00:08:28,800 --> 00:08:36,940
You can make an array of size 256 and obviously this added will be a boolean Eddie and you can use this

143
00:08:36,940 --> 00:08:37,990
approach for example.

144
00:08:38,020 --> 00:08:40,290
So go to next 97.

145
00:08:40,460 --> 00:08:42,020
So initially this was false.

146
00:08:42,020 --> 00:08:42,970
What do you will do.

147
00:08:42,980 --> 00:08:47,720
So you will see false you will push inside the vector and then you will make it true.

148
00:08:47,780 --> 00:08:49,470
Similarly won't even come again.

149
00:08:49,490 --> 00:08:50,850
You will go to index 97.

150
00:08:50,870 --> 00:08:53,750
So this is true then do not push E again.

151
00:08:53,750 --> 00:08:54,360
See.

152
00:08:54,380 --> 00:09:00,890
So go to index 97 seven ninety nine and it will check it is false so you will make it through you will

153
00:09:00,890 --> 00:09:02,690
push it C and so on.

154
00:09:02,690 --> 00:09:07,040
So basically if the character was given you can definitely use this boolean idea approach.

155
00:09:07,040 --> 00:09:11,680
But since we have a beta today and indeed it can be very big and indeed can be negative also.

156
00:09:11,690 --> 00:09:18,970
So we have to use map in this equation so that our time complexity can be linear.

157
00:09:19,120 --> 00:09:20,590
Okay so how can we use map.

158
00:09:20,620 --> 00:09:22,770
So it is very very simple.

159
00:09:22,990 --> 00:09:24,670
So consider it a very small example.

160
00:09:24,760 --> 00:09:27,200
So considered above an example.

161
00:09:27,250 --> 00:09:27,970
So what do we lose.

162
00:09:27,970 --> 00:09:33,100
So I have this construct this integer area so one two three then two then one.

163
00:09:33,100 --> 00:09:36,460
Then let's say 5 4 1 and 3.

164
00:09:36,490 --> 00:09:37,590
So what will I do.

165
00:09:37,610 --> 00:09:39,180
I am going to construct a map.

166
00:09:39,190 --> 00:09:41,730
So let's say the name of map is my map.

167
00:09:41,860 --> 00:09:42,630
Give a loop.

168
00:09:42,750 --> 00:09:48,160
Key will be element and value will be basically true or false.

169
00:09:48,160 --> 00:09:49,490
So what do we do.

170
00:09:49,510 --> 00:09:51,210
So pick the first element no check.

171
00:09:51,220 --> 00:09:52,860
So initially my map is empty.

172
00:09:52,870 --> 00:09:57,550
So this is map so it usually map is empty no check.

173
00:09:57,580 --> 00:09:59,470
So 1 percent inside the map.

174
00:09:59,530 --> 00:10:00,670
No it is not present.

175
00:10:00,670 --> 00:10:07,030
So what you will do you will push 1 and one adult 2 so the value of 1 is true and you will push a button

176
00:10:07,030 --> 00:10:08,870
inside of it but no 2.

177
00:10:09,370 --> 00:10:11,460
So to present inside the map no.

178
00:10:11,470 --> 00:10:14,730
So push 2 and make it through no 3.

179
00:10:14,740 --> 00:10:16,140
So 3 pleasantly inside the map.

180
00:10:16,150 --> 00:10:16,790
No.

181
00:10:16,840 --> 00:10:19,170
Then push 3 inside the map and make it through.

182
00:10:19,330 --> 00:10:24,400
So obviously then you will push inside the map you will also push inside the vector so you will also

183
00:10:24,400 --> 00:10:26,270
push inside director.

184
00:10:26,320 --> 00:10:28,780
So this is the vector that we have to return.

185
00:10:28,810 --> 00:10:29,790
Okay.

186
00:10:29,980 --> 00:10:31,320
Now again 2 is coming.

187
00:10:31,420 --> 00:10:33,280
So two is already present inside the map.

188
00:10:33,310 --> 00:10:34,710
So do not do anything.

189
00:10:34,720 --> 00:10:37,060
1 so 1 is already present inside the map.

190
00:10:37,060 --> 00:10:38,380
Do not do anything.

191
00:10:38,380 --> 00:10:39,840
5 5 is not president.

192
00:10:39,850 --> 00:10:44,520
Then you will push 5 inside the map and you will also push 5 inside.

193
00:10:44,530 --> 00:10:47,080
Direct but then forward.

194
00:10:47,080 --> 00:10:49,660
So far it is not present inside the map.

195
00:10:49,660 --> 00:10:54,460
So you will make it through and you will push forward inside the vector then again.

196
00:10:54,470 --> 00:10:57,970
1 so 1 is present then 3.

197
00:10:58,090 --> 00:11:00,340
So to use present and this will be your answer.

198
00:11:01,410 --> 00:11:02,690
This will be your own set okay.

199
00:11:02,700 --> 00:11:08,810
So searching in map so we will use guard count function as discussed in the previous video.

200
00:11:08,820 --> 00:11:11,770
So this time complexity of current function is constant.

201
00:11:11,790 --> 00:11:17,940
If you are using an order to map and if you are using map then the time complexity will be log in so

202
00:11:17,940 --> 00:11:21,360
we will use on our road map so that time complexity is constraint.

203
00:11:21,450 --> 00:11:25,600
So with the help of map begins all discussion in linear time.

204
00:11:25,680 --> 00:11:27,740
Now let us write the code for this question.

205
00:11:27,840 --> 00:11:29,780
A case of code is going to look very very simple.

206
00:11:32,470 --> 00:11:37,000
So what we have to do we have to return our function will done.

207
00:11:37,000 --> 00:11:44,910
Basically vector of integers and let's say the name of the function is basically remove duplicates so

208
00:11:45,030 --> 00:11:46,110
what this function will take.

209
00:11:46,140 --> 00:11:53,900
So this function will take an integer that is input and obviously it will take size also and then ready

210
00:11:53,920 --> 00:12:02,360
have to do what it does first create our vector of so first let us cleared our output vector of integers

211
00:12:02,450 --> 00:12:03,340
and output.

212
00:12:03,500 --> 00:12:06,880
So it will contain all the unique elements and in the same order.

213
00:12:07,110 --> 00:12:18,080
And now let us all to create an order to map so key will be element started given three digit and value

214
00:12:18,080 --> 00:12:20,830
will be basically Boolean value true or false.

215
00:12:20,830 --> 00:12:21,990
And let's see the name of my.

216
00:12:22,040 --> 00:12:26,540
Is my map so you can see yourself.

217
00:12:26,540 --> 00:12:30,100
So the structure of my map is very simple.

218
00:12:30,140 --> 00:12:30,950
Give a loop here.

219
00:12:30,980 --> 00:12:36,500
So key is going to be element and element is integer and this is going to be true or false.

220
00:12:36,530 --> 00:12:41,730
So basically boolean value so key and integer 10 billion.

221
00:12:42,530 --> 00:12:44,010
Initially my map is empty.

222
00:12:44,090 --> 00:12:47,710
Then what we have to do so now let us outraged over the array.

223
00:12:47,750 --> 00:12:49,700
So I equals zero.

224
00:12:49,700 --> 00:12:53,740
I list in a plus plus now.

225
00:12:53,760 --> 00:12:56,380
Let us search whether this element is president or not.

226
00:12:56,470 --> 00:12:57,750
So I will use common function.

227
00:12:57,760 --> 00:12:58,610
So my map.

228
00:12:58,630 --> 00:12:59,870
Dot com.

229
00:13:00,220 --> 00:13:02,430
So what it will take it will take as inputs.

230
00:13:02,450 --> 00:13:05,270
Key basically means element element is indigent.

231
00:13:05,350 --> 00:13:08,620
So if if I equals equals zero.

232
00:13:08,620 --> 00:13:11,460
So I told you can't function will only return two things.

233
00:13:11,500 --> 00:13:13,640
0 and 1 0 means not present.

234
00:13:13,660 --> 00:13:18,410
So if the element is not present inside the map that means it is coming for the first time.

235
00:13:18,430 --> 00:13:24,670
So if it is coming for the first time you will push it inside your vector because it is coming for the

236
00:13:24,670 --> 00:13:25,690
first time.

237
00:13:25,780 --> 00:13:26,960
So output not pushback.

238
00:13:27,010 --> 00:13:30,580
If I and also you will push it inside the map.

239
00:13:30,580 --> 00:13:37,290
So my map dart push slightly my map and this grid backwards.

240
00:13:37,470 --> 00:13:42,410
So if I is basically true.

241
00:13:42,520 --> 00:13:43,730
Okay so this is key.

242
00:13:43,860 --> 00:13:45,230
And this is value.

243
00:13:45,240 --> 00:13:49,580
So EFI is key and this is value so my map of EFI is true.

244
00:13:49,650 --> 00:13:52,500
And finally where you can do you can get done.

245
00:13:52,650 --> 00:13:54,640
You get a vector so it done.

246
00:13:54,670 --> 00:13:55,110
Output

247
00:13:57,760 --> 00:13:58,550
simple.

248
00:13:58,600 --> 00:14:01,420
Now let us create an edit here and let us just start program.

249
00:14:03,590 --> 00:14:09,830
So let's give the elements so.

250
00:14:09,910 --> 00:14:14,510
So this is the edit and now let us call the function

251
00:14:17,620 --> 00:14:22,270
selector and output so name of the function is remove duplicates

252
00:14:26,760 --> 00:14:30,860
this function will take added as input and what is the size of the array so.

253
00:14:30,960 --> 00:14:37,680
So one two three four five six seven eight nine ten eleven and twelve so they are total twelve elements

254
00:14:37,680 --> 00:14:39,450
so the size of that is twin.

255
00:14:39,750 --> 00:14:44,780
And now let us bring down the vector so that we can see the output.

256
00:14:44,850 --> 00:14:52,120
So like close to zero I list in product size a plus plus

257
00:15:03,480 --> 00:15:04,100
no first.

258
00:15:04,130 --> 00:15:11,620
Before running this program let's see what our output should be so when one is coming for the first

259
00:15:11,620 --> 00:15:16,330
time then 5 is going for the first time 2 is coming for the first time for is going for the first time

260
00:15:16,700 --> 00:15:22,730
will not take this forward then 3 is coming for the first time so we will not take this tree.

261
00:15:22,770 --> 00:15:25,950
We will take six videos or take seven.

262
00:15:25,950 --> 00:15:27,850
We will not take one we will not take one.

263
00:15:27,850 --> 00:15:29,090
We will not take two.

264
00:15:29,100 --> 00:15:30,600
So this should be our answer.

265
00:15:32,250 --> 00:15:35,860
1 5 2 4 2 6 7 1 5 2 4 2 6 7.

266
00:15:35,970 --> 00:15:37,050
So let's see.

267
00:15:37,730 --> 00:15:38,460
It's an apple.

268
00:15:40,590 --> 00:15:40,830
Okay.

269
00:15:40,830 --> 00:15:43,340
So basically we have to include vector.

270
00:15:43,350 --> 00:15:45,680
We have to include an order to map.

271
00:15:45,750 --> 00:15:48,450
So instead of including these two we can write

272
00:15:54,000 --> 00:15:58,800
so then I'll let them know program.

273
00:15:59,080 --> 00:16:02,870
Okay so my method count what is the idea.

274
00:16:02,890 --> 00:16:07,620
So if my map not count if I.

275
00:16:07,730 --> 00:16:10,130
Okay so the name of that is error.

276
00:16:10,220 --> 00:16:13,680
So let's change the name.

277
00:16:13,870 --> 00:16:19,540
The name is no.

278
00:16:19,580 --> 00:16:23,480
So this is the output 1 5 2 4 2 6 7.

279
00:16:23,480 --> 00:16:30,170
So our output is right as discussed when 5 246 7 so all the elements are unique and elements that are

280
00:16:30,170 --> 00:16:31,970
appearing in the same order.

281
00:16:31,970 --> 00:16:35,030
Now let us discuss what is the time complexity of a solution

282
00:16:39,060 --> 00:16:40,270
know what we are doing here.

283
00:16:40,270 --> 00:16:42,160
So we are just getting already today.

284
00:16:42,340 --> 00:16:45,520
And basically this current function will take constraint time.

285
00:16:45,520 --> 00:16:48,970
This pushback will take constraint time and this insertion will take constant time.

286
00:16:49,270 --> 00:16:53,110
So our time complexity is basically linear.

287
00:16:53,210 --> 00:16:58,910
Now if you're using map so instead of using an order to map if you will use map then what will happen.

288
00:16:58,910 --> 00:17:03,890
So this current function will take logging time and this insertion function will also take logging time

289
00:17:04,120 --> 00:17:10,780
so a time complexity will become and log in so this is the time complexity if you will use map.

290
00:17:10,790 --> 00:17:18,580
And this is the time complexity if you will use unordered map and this is my output so all the elements

291
00:17:18,580 --> 00:17:21,280
are unique and elements are appearing in the same order.

292
00:17:21,310 --> 00:17:27,090
So you can see when 5 then 2 then forward and then 3 6 and 7.

293
00:17:27,220 --> 00:17:29,710
So 1 5 2 4 2 6 7.

294
00:17:29,800 --> 00:17:31,850
So I hope you understood this.

295
00:17:32,110 --> 00:17:33,660
I hope you understood discussion also.

296
00:17:35,110 --> 00:17:36,270
I will see you in the next one.

297
00:17:36,370 --> 00:17:38,050
And if you're having it out you can ask me.

298
00:17:38,050 --> 00:17:38,470
Bye bye.

299
00:17:38,500 --> 00:17:38,880
Thank you.
