1
00:00:02,490 --> 00:00:04,260
Hey, guys, what's up?

2
00:00:05,040 --> 00:00:07,590
So we are solving another interesting problem today.

3
00:00:08,250 --> 00:00:14,130
So the problem is given a number and given a number.

4
00:00:16,170 --> 00:00:18,220
And we have to today.

5
00:00:21,090 --> 00:00:21,610
We have to.

6
00:00:23,640 --> 00:00:24,840
How many times?

7
00:00:26,370 --> 00:00:30,620
How many times when I'll be at.

8
00:00:33,600 --> 00:00:37,260
And it's binary representation.

9
00:00:41,410 --> 00:00:46,510
So we have to tell how I mean, at times when I appear in the binary representation of dead.

10
00:00:46,560 --> 00:00:46,860
No.

11
00:00:47,440 --> 00:00:49,270
For example, the given number is five.

12
00:00:49,630 --> 00:00:54,340
So the binary presentation of five is zero zero zero one zero one.

13
00:00:54,910 --> 00:00:58,200
So my output should be to.

14
00:00:59,320 --> 00:01:01,660
Let's say four and equals to seven and four.

15
00:01:01,660 --> 00:01:02,650
And it was 15.

16
00:01:04,360 --> 00:01:07,090
So here my output is when, when, when.

17
00:01:08,500 --> 00:01:11,080
So I have my own binary presentation is one when one.

18
00:01:11,530 --> 00:01:14,890
So my output will be three and four fifteen.

19
00:01:14,980 --> 00:01:21,870
My binary presentation will be this and the output will be four because there are four ones.

20
00:01:22,720 --> 00:01:29,290
So given a number and we have to tell how many times will not be in its binary representation.

21
00:01:30,300 --> 00:01:34,130
So actually, one is also going to set a bit.

22
00:01:36,690 --> 00:01:40,840
So you can also say this problem is calculated.

23
00:01:42,760 --> 00:01:48,180
Number of sentiment's in ENIM but.

24
00:01:49,700 --> 00:01:58,000
In binary representation of a number in binary is imitation offer, no.

25
00:01:58,760 --> 00:01:59,960
So sad, but it is nothing.

26
00:02:00,380 --> 00:02:02,470
It is just when one is called said but.

27
00:02:03,920 --> 00:02:10,860
OK, so this problem can also be in this session, also hear the number of securites in Bindoon presentation

28
00:02:10,860 --> 00:02:11,810
of a number.

29
00:02:12,600 --> 00:02:14,840
So any idea how we can solve it?

30
00:02:17,320 --> 00:02:21,550
So we have to use bitwise operators to solve this problem.

31
00:02:22,900 --> 00:02:27,130
So suppose and it was seven.

32
00:02:27,190 --> 00:02:28,650
So what is that binary presentation?

33
00:02:28,660 --> 00:02:31,960
Seven zero zero zero and one one in one.

34
00:02:32,950 --> 00:02:33,940
So what do I really do?

35
00:02:34,060 --> 00:02:35,500
First of all, I will take.

36
00:02:36,570 --> 00:02:37,080
No.

37
00:02:37,170 --> 00:02:38,010
And when?

38
00:02:40,920 --> 00:02:41,170
OK.

39
00:02:41,920 --> 00:02:43,370
Take no end one.

40
00:02:44,760 --> 00:02:48,720
So binary presentation of one is one and zero zero zero zero zero.

41
00:02:49,350 --> 00:02:50,270
So we have to take.

42
00:02:50,400 --> 00:02:53,880
And so since it is zero zero zero zero zero.

43
00:02:53,940 --> 00:02:55,500
So output will be zero zero zero.

44
00:02:55,530 --> 00:03:01,020
And two, because if you remember the end on one and one will give me one.

45
00:03:01,230 --> 00:03:03,510
Otherwise, all of their cases will give me zero.

46
00:03:03,930 --> 00:03:06,350
So if there is one zero, all parties zero.

47
00:03:07,290 --> 00:03:08,520
Now let us focus.

48
00:03:08,580 --> 00:03:09,810
What will you output here?

49
00:03:11,350 --> 00:03:14,500
So output is one and one is one.

50
00:03:15,080 --> 00:03:17,440
Now convert this number into decimal.

51
00:03:18,040 --> 00:03:18,490
So when.

52
00:03:20,290 --> 00:03:21,570
OK, so.

53
00:03:21,880 --> 00:03:24,100
And and one is giving me one.

54
00:03:26,120 --> 00:03:27,740
Now, I will update the number.

55
00:03:28,190 --> 00:03:29,120
What I will do, I will.

56
00:03:29,450 --> 00:03:31,610
I will shift the number towards.

57
00:03:31,920 --> 00:03:32,300
Right.

58
00:03:32,780 --> 00:03:36,420
So no liquids, no light shift one.

59
00:03:37,400 --> 00:03:42,890
So my number become zero zero zero zero one and one.

60
00:03:42,920 --> 00:03:45,490
So this is my updated number again.

61
00:03:45,740 --> 00:03:47,620
I will take no and when.

62
00:03:49,130 --> 00:03:51,370
So here I am having one less dollar.

63
00:03:51,460 --> 00:03:51,820
Zero.

64
00:03:53,990 --> 00:03:54,570
We have to take.

65
00:03:54,600 --> 00:03:56,960
And so zero zero zero zero zero.

66
00:03:57,320 --> 00:03:59,720
So one and one is one.

67
00:04:01,550 --> 00:04:02,740
So I am getting one again.

68
00:04:03,170 --> 00:04:06,600
Now I will update the number again number as it goes to a number.

69
00:04:06,680 --> 00:04:07,850
Let's shift one.

70
00:04:08,900 --> 00:04:10,610
So number equals number.

71
00:04:10,960 --> 00:04:11,120
Right.

72
00:04:11,240 --> 00:04:11,960
Shift one.

73
00:04:12,530 --> 00:04:15,590
So zero zero zero zero zero.

74
00:04:15,620 --> 00:04:16,030
And one.

75
00:04:17,720 --> 00:04:18,630
Now we have to take.

76
00:04:18,650 --> 00:04:20,060
Number and one.

77
00:04:20,540 --> 00:04:22,700
So zero zero zero zero zero.

78
00:04:22,970 --> 00:04:25,250
And when we have to take.

79
00:04:25,310 --> 00:04:28,160
And so this will be zero zero zero zero zero.

80
00:04:28,760 --> 00:04:30,490
So one and one is one.

81
00:04:30,940 --> 00:04:32,390
Again, remember when.

82
00:04:33,140 --> 00:04:36,170
Now we again shift the number.

83
00:04:37,310 --> 00:04:39,050
So number equals number.

84
00:04:39,140 --> 00:04:39,420
Right.

85
00:04:39,450 --> 00:04:40,400
Shift one.

86
00:04:40,790 --> 00:04:43,820
So it will become zero zero zero zero zero and zero.

87
00:04:44,120 --> 00:04:45,500
So number becomes zero.

88
00:04:45,560 --> 00:04:46,040
Stop.

89
00:04:48,110 --> 00:04:49,280
Number becomes zero.

90
00:04:49,700 --> 00:04:50,210
Stop.

91
00:04:52,180 --> 00:04:56,130
And now we will see how they will calculate our output.

92
00:04:58,100 --> 00:05:03,430
So here you can see one, one and one.

93
00:05:04,000 --> 00:05:06,020
Adam, my output is three.

94
00:05:06,470 --> 00:05:13,610
So in binary presentation of seven, you can see one appeared two times.

95
00:05:16,680 --> 00:05:17,960
OK, so this is the logic.

96
00:05:18,960 --> 00:05:21,330
Let's try our logic for one more kiss.

97
00:05:21,930 --> 00:05:22,530
Suppose.

98
00:05:22,760 --> 00:05:23,920
And it was five.

99
00:05:24,120 --> 00:05:32,620
So it is the binding presentation of five zero zero one zero one dick and with one number equals.

100
00:05:33,210 --> 00:05:33,630
Sorry.

101
00:05:34,030 --> 00:05:34,440
No.

102
00:05:34,560 --> 00:05:35,190
And one.

103
00:05:37,170 --> 00:05:40,410
So this is the binding presentation of one zero zero zero zero.

104
00:05:41,070 --> 00:05:41,670
We have to take.

105
00:05:41,730 --> 00:05:44,970
And so since this is zero zero zero zero.

106
00:05:45,000 --> 00:05:45,790
This is zero zero.

107
00:05:45,810 --> 00:05:46,920
This is zero zero.

108
00:05:47,310 --> 00:05:50,670
Because only one end of one is one arrest or a lot of zero.

109
00:05:51,480 --> 00:05:52,480
Now take one.

110
00:05:52,540 --> 00:05:54,300
And one is one.

111
00:05:55,810 --> 00:05:56,910
So remember one here.

112
00:05:57,840 --> 00:05:59,400
Now I will update my number.

113
00:05:59,430 --> 00:06:00,570
Number equals number.

114
00:06:00,660 --> 00:06:00,870
Right.

115
00:06:00,930 --> 00:06:01,590
Shift one.

116
00:06:02,190 --> 00:06:03,510
So shift the number towards.

117
00:06:03,600 --> 00:06:03,990
Right.

118
00:06:04,740 --> 00:06:07,170
So zero zero zero one and zero.

119
00:06:08,130 --> 00:06:09,930
And now number and one.

120
00:06:13,350 --> 00:06:14,250
So this is one.

121
00:06:15,200 --> 00:06:15,990
And we have to take.

122
00:06:16,070 --> 00:06:18,120
And so since this is zero.

123
00:06:18,360 --> 00:06:19,260
Since this is zero.

124
00:06:19,320 --> 00:06:20,310
Since this is zero.

125
00:06:20,340 --> 00:06:21,510
Since this is zero.

126
00:06:22,240 --> 00:06:25,170
Now if and of one zero will also be zero.

127
00:06:25,200 --> 00:06:27,360
Because only one end of one is one.

128
00:06:27,780 --> 00:06:29,010
Otherwise all at zero.

129
00:06:29,490 --> 00:06:31,630
So this number is giving me zero.

130
00:06:33,040 --> 00:06:33,430
Again.

131
00:06:33,560 --> 00:06:33,700
Right.

132
00:06:33,730 --> 00:06:35,460
Check the number by one.

133
00:06:36,240 --> 00:06:39,630
So why number becomes zero zero zero zero.

134
00:06:39,690 --> 00:06:40,080
And one.

135
00:06:41,250 --> 00:06:42,840
And number.

136
00:06:42,840 --> 00:06:43,530
And one.

137
00:06:44,190 --> 00:06:46,370
So zero zero zero zero one.

138
00:06:46,680 --> 00:06:50,000
We have Rubick and one zero zero zero zero.

139
00:06:50,640 --> 00:06:52,380
So it is giving me one.

140
00:06:53,190 --> 00:06:55,140
Now, if we will shift one more time.

141
00:06:55,410 --> 00:06:56,520
Number towards right.

142
00:06:56,580 --> 00:07:00,150
It will become zero zero zero zero zero, which is zero.

143
00:07:00,890 --> 00:07:01,760
So it will become zero.

144
00:07:01,810 --> 00:07:03,060
Hence I will stop.

145
00:07:03,630 --> 00:07:10,020
Now add all these one plus zero plus one gives me two.

146
00:07:10,560 --> 00:07:11,280
You can see here.

147
00:07:11,310 --> 00:07:14,040
Binary presentation in binary presentation of five.

148
00:07:15,610 --> 00:07:16,620
Arbitrary two.

149
00:07:16,890 --> 00:07:18,570
And I'm getting to.

150
00:07:19,610 --> 00:07:22,340
Now, one last example, number is one.

151
00:07:23,630 --> 00:07:26,620
OK, so binary visitation of one is zero zero zero one.

152
00:07:26,660 --> 00:07:27,140
Let's one.

153
00:07:28,520 --> 00:07:30,680
And we have to take a number and one.

154
00:07:31,510 --> 00:07:34,040
So zero zero zero one big.

155
00:07:34,100 --> 00:07:38,300
And so since this is zero one zero assistances, zero zero since this is zero zero.

156
00:07:38,630 --> 00:07:45,170
And here I will get one convert the number and decimal I may get one number equals number shift one.

157
00:07:45,710 --> 00:07:49,160
So if you will share the number two right, it will become zero.

158
00:07:49,220 --> 00:07:50,120
I will stop.

159
00:07:50,600 --> 00:07:52,250
And this is my answer.

160
00:07:54,330 --> 00:07:54,550
OK.

161
00:07:55,810 --> 00:08:04,900
So what I will do, I will take a variable and count it equals zero initially my variable count will

162
00:08:04,900 --> 00:08:05,890
contain zero.

163
00:08:06,190 --> 00:08:06,940
What is count?

164
00:08:07,240 --> 00:08:09,050
Count is how many times when appear.

165
00:08:10,120 --> 00:08:14,710
Guys are going to a table will store how many times when appear in the binary representation of a number.

166
00:08:15,340 --> 00:08:16,900
So end count equals zero.

167
00:08:17,890 --> 00:08:21,650
How many times I have to run the loop while Lember is bigger than zero.

168
00:08:22,690 --> 00:08:25,400
And what I have to do, I have to take and off.

169
00:08:25,420 --> 00:08:25,780
Number.

170
00:08:26,310 --> 00:08:34,180
OK, so count equals count plus number and one.

171
00:08:35,740 --> 00:08:40,210
OK, so this value will either be one or this value will either be zero.

172
00:08:40,360 --> 00:08:42,010
There are no other possibilities.

173
00:08:42,280 --> 00:08:42,560
OK.

174
00:08:42,850 --> 00:08:43,900
Either it will be zero.

175
00:08:44,020 --> 00:08:44,880
Either it will be one.

176
00:08:46,720 --> 00:08:48,290
And then we will update our number.

177
00:08:48,310 --> 00:08:49,470
Number equals number.

178
00:08:49,520 --> 00:08:49,790
Right.

179
00:08:49,810 --> 00:08:50,650
Shift one.

180
00:08:51,880 --> 00:08:53,410
Finally we will see out.

181
00:08:55,570 --> 00:08:55,980
Gonged.

182
00:08:57,420 --> 00:08:57,610
OK.

183
00:08:57,700 --> 00:09:00,710
So I am saying that there are only two possibilities.

184
00:09:00,770 --> 00:09:04,830
Either this number will be zero or the number that we will get is when.

185
00:09:05,240 --> 00:09:09,410
If this number is at zero, it will not have any effect on account variable.

186
00:09:10,580 --> 00:09:17,500
It will not have any effect on my variable count, because if you add a zero to a number, it will remain

187
00:09:17,500 --> 00:09:17,840
the same.

188
00:09:18,560 --> 00:09:23,210
But if it is one, that means card will be implemented by one.

189
00:09:24,080 --> 00:09:24,590
Now why?

190
00:09:24,610 --> 00:09:29,860
I am saying that the number will either be zero or the number will either be one because I'm taking

191
00:09:29,870 --> 00:09:30,650
and with one.

192
00:09:31,460 --> 00:09:31,720
OK.

193
00:09:32,030 --> 00:09:38,540
So here binary presentation of one is one and rest or allows you to suppose this is binary number.

194
00:09:39,950 --> 00:09:46,640
And if you take and it doesn't matter whether X is zero or one, these four bits are going to be zero

195
00:09:46,830 --> 00:09:47,200
only.

196
00:09:47,980 --> 00:09:49,400
This bit if they're deciding.

197
00:09:50,850 --> 00:09:51,030
OK.

198
00:09:51,170 --> 00:09:55,100
So if X is one, if X is one, I really get one here.

199
00:09:55,670 --> 00:09:58,310
If X is zero, I will get zero here.

200
00:09:58,790 --> 00:10:06,050
And if you will convert, if you will convert this number to decimal, it is one.

201
00:10:06,440 --> 00:10:08,660
If you convert this number two decimal, it is zero.

202
00:10:08,720 --> 00:10:10,740
So there are only two possibilities that I will get.

203
00:10:10,760 --> 00:10:13,730
One, that I will get zero if I am getting zero.

204
00:10:14,000 --> 00:10:15,770
There is no effect on Gonta variable.

205
00:10:16,040 --> 00:10:23,930
If I'm getting one, that means that here I was having one and one means set with and we have to calculate

206
00:10:23,960 --> 00:10:24,980
the set with only.

207
00:10:25,580 --> 00:10:27,590
So it will be added to my variable count.

208
00:10:28,850 --> 00:10:29,990
OK, so that is the logic.

209
00:10:30,290 --> 00:10:31,070
So what is the logic?

210
00:10:31,110 --> 00:10:38,930
Logic is very simple, just shifted the number towards right and Dick and with the last digit back end

211
00:10:38,930 --> 00:10:39,650
of the last digit.

212
00:10:39,980 --> 00:10:44,750
If last digit is one, I will get one and count will be incremented.

213
00:10:45,320 --> 00:10:46,940
If the last digit is zero.

214
00:10:47,330 --> 00:10:53,600
If last digit is zero, I will get zero and zero and one zero and one will be zero.

215
00:10:53,720 --> 00:10:55,310
So card will not be effected.

216
00:10:58,570 --> 00:11:07,540
So I know this thing is a difficult to understand, but what you should do is, again, it is it just

217
00:11:07,540 --> 00:11:08,830
comes with practice only.

218
00:11:10,250 --> 00:11:18,110
So what you should do is use pen and paper and write down the steps which are involved in solving the

219
00:11:18,170 --> 00:11:18,620
problem.

220
00:11:19,790 --> 00:11:21,320
So let us name this file as.

221
00:11:23,390 --> 00:11:24,220
Nemeroff.

222
00:11:28,380 --> 00:11:29,550
No off when.

223
00:11:32,330 --> 00:11:33,190
Nazi CPB.

224
00:11:43,900 --> 00:11:44,950
So what do we have to do?

225
00:11:45,220 --> 00:11:46,870
I will take and as input.

226
00:11:50,660 --> 00:11:58,150
And I am taking a variable count which will tell me how many times when I appeared in the binary presentation.

227
00:11:58,190 --> 00:11:59,600
So initially I can't really be zero.

228
00:12:00,830 --> 00:12:05,230
So why in my number is greater than zero.

229
00:12:06,360 --> 00:12:07,070
What I will do.

230
00:12:11,430 --> 00:12:14,500
Clowned plus equals to No.

231
00:12:16,250 --> 00:12:18,500
And one.

232
00:12:20,330 --> 00:12:21,780
OK, so this is a tricky part.

233
00:12:22,100 --> 00:12:23,220
But why this tricky?

234
00:12:23,360 --> 00:12:26,570
Because you have not practiced any problem of this kind.

235
00:12:27,590 --> 00:12:30,140
So you may be facing very difficult days, I know.

236
00:12:30,980 --> 00:12:32,150
And that is obvious.

237
00:12:32,420 --> 00:12:35,990
That is very natural because you have notes, all these kinds of problem.

238
00:12:36,410 --> 00:12:38,360
So how you can come up with the solution.

239
00:12:38,520 --> 00:12:40,280
Obviously, you can't come up.

240
00:12:41,330 --> 00:12:47,230
OK, so once we have solved this type of question, then you will be able to understand it, how we

241
00:12:47,230 --> 00:12:47,860
can solve it.

242
00:12:48,010 --> 00:12:48,290
OK.

243
00:12:49,870 --> 00:12:53,710
So no end you that this will be zero or one.

244
00:12:54,490 --> 00:12:55,870
And we have to upgrade the number.

245
00:12:55,960 --> 00:12:58,150
So number equals number.

246
00:12:58,530 --> 00:12:58,760
Right.

247
00:12:58,800 --> 00:12:59,640
Shift one.

248
00:13:00,790 --> 00:13:06,410
And then finally, we will see out count.

249
00:13:07,450 --> 00:13:09,700
So this is all that we have to do.

250
00:13:12,320 --> 00:13:13,400
So let's not vote on.

251
00:13:17,260 --> 00:13:21,280
So for any good faith, my approach would be to correct.

252
00:13:25,830 --> 00:13:26,340
Four.

253
00:13:26,500 --> 00:13:31,580
And it was seven, my output should be three, correct?

254
00:13:37,100 --> 00:13:42,470
For any clues, let's say, when Marbut should be when correct?

255
00:13:44,280 --> 00:13:45,900
Shalako is correct.

256
00:13:46,500 --> 00:13:47,370
So when last time.

257
00:13:47,400 --> 00:13:51,390
I know it is very difficult to understand how I approached this problem.

258
00:13:51,840 --> 00:13:53,370
How do I know that it will work?

259
00:13:54,620 --> 00:14:00,140
And why it is difficult for you, because this is your first time, your first time encountering these

260
00:14:00,140 --> 00:14:00,900
types of problem.

261
00:14:01,610 --> 00:14:03,230
So it is very difficult to understand.

262
00:14:03,290 --> 00:14:03,680
I know.

263
00:14:05,790 --> 00:14:09,150
So what do you do is you will write discord on pen and paper.

264
00:14:10,300 --> 00:14:12,510
Take some values, often drive in your code.

265
00:14:12,890 --> 00:14:16,960
The steps that are involved in each step right there look for the value of count.

266
00:14:17,270 --> 00:14:19,590
What is an end of one road shift?

267
00:14:19,640 --> 00:14:21,770
And by one and all these steps.

268
00:14:23,210 --> 00:14:23,490
OK.

269
00:14:24,510 --> 00:14:27,090
So if you have any problem, feel free to ask.

270
00:14:27,250 --> 00:14:27,560
OK.

271
00:14:28,800 --> 00:14:30,120
So this is it for this video.

272
00:14:30,570 --> 00:14:31,020
Thank you.
