1
00:00:01,500 --> 00:00:02,110
Hello everyone.

2
00:00:02,150 --> 00:00:03,140
Welcome to the session.

3
00:00:03,140 --> 00:00:06,110
So today we will solve one more problem with the help of the occasion.

4
00:00:06,140 --> 00:00:08,840
So the name of the problem is currency it.

5
00:00:09,290 --> 00:00:11,600
OK so what is the problem.

6
00:00:11,600 --> 00:00:17,760
So the problem is very simple given a number let's say the number is 1 0 3 2 0.

7
00:00:17,840 --> 00:00:20,300
So we have to calculate how many zeros at present.

8
00:00:20,330 --> 00:00:22,420
So in this case our output will be two.

9
00:00:22,440 --> 00:00:22,720
Okay.

10
00:00:22,730 --> 00:00:26,490
Because there are two zeros okay.

11
00:00:26,500 --> 00:00:30,340
Now let's take one more example of the value of and this let's say 123.

12
00:00:30,340 --> 00:00:33,390
Then output will be zero because there are no 0 present.

13
00:00:33,760 --> 00:00:34,210
OK.

14
00:00:34,270 --> 00:00:39,420
So I hope you've got the problem we just have to count the number of zeros present inside the number.

15
00:00:39,860 --> 00:00:42,390
OK now how we can solve this problem.

16
00:00:42,400 --> 00:00:45,700
So basically what we have to do we will go to each and every digit.

17
00:00:46,180 --> 00:00:47,940
We will go to each and every digit.

18
00:00:47,950 --> 00:00:52,420
And if the digit is 0 we will do our answer plus plus.

19
00:00:52,420 --> 00:00:52,650
Okay.

20
00:00:52,660 --> 00:00:56,200
So this was the approach of when we are using for loop of divine loop.

21
00:00:56,200 --> 00:00:56,730
OK.

22
00:00:56,890 --> 00:01:00,190
Now we will use a similar approach if we are using recursion also.

23
00:01:00,190 --> 00:01:01,400
So what we will do.

24
00:01:01,450 --> 00:01:05,850
So given that the Model T the number is 1 0 2 2 0 only.

25
00:01:05,920 --> 00:01:07,060
So what I will do.

26
00:01:07,060 --> 00:01:10,180
So I will tell that equation.

27
00:01:10,180 --> 00:01:12,820
Give me how many zeros at present in this Malone.

28
00:01:12,910 --> 00:01:16,370
So the equation will give me that answer for this is one.

29
00:01:16,420 --> 00:01:16,630
Okay.

30
00:01:16,660 --> 00:01:21,550
Because there are 1 0 present then what we will do we will check the last digit.

31
00:01:21,820 --> 00:01:22,380
OK.

32
00:01:22,450 --> 00:01:27,730
We will check this last digit OK.

33
00:01:27,740 --> 00:01:29,060
So this last digit is it.

34
00:01:29,070 --> 00:01:29,830
So what do we do.

35
00:01:29,840 --> 00:01:31,760
We will do one plus one.

36
00:01:31,820 --> 00:01:32,350
OK.

37
00:01:32,510 --> 00:01:34,790
Since the last budget is it what we will do plus one.

38
00:01:34,790 --> 00:01:37,730
So the answer will become to OK.

39
00:01:37,760 --> 00:01:40,670
So this is how this code will work if we want to.

40
00:01:40,670 --> 00:01:43,120
So this will be now.

41
00:01:43,240 --> 00:01:45,410
This is the function count zeros.

42
00:01:45,730 --> 00:01:48,010
It will take a number and as argument.

43
00:01:48,010 --> 00:01:49,180
What I will do.

44
00:01:49,180 --> 00:01:55,490
So this cone zeros function concludes the count convert the number of zeros present inside the number.

45
00:01:55,480 --> 00:01:57,690
And so I will give the smaller input.

46
00:01:58,000 --> 00:02:00,610
So it will give me how many zeros at present in the number.

47
00:02:00,610 --> 00:02:01,580
And by 10.

48
00:02:01,630 --> 00:02:05,520
So this is basically and by 10 OK.

49
00:02:05,530 --> 00:02:07,660
So this will be our problem.

50
00:02:07,690 --> 00:02:09,880
This will be done stuff with a similar problem.

51
00:02:09,880 --> 00:02:12,020
And then we will check the last digit.

52
00:02:12,370 --> 00:02:17,200
OK so we will check if the last digit in this case it is 0 here.

53
00:02:17,230 --> 00:02:23,380
So if the last digit is 0 what we will do we will add plus 1 to our answer.

54
00:02:23,410 --> 00:02:26,770
So this was our smaller answer.

55
00:02:26,770 --> 00:02:27,540
So what do we do.

56
00:02:27,550 --> 00:02:34,330
We will lose more Laron said plus plus or we can write a small lines plus one in the each part.

57
00:02:34,330 --> 00:02:38,780
You will simply there done smaller answer or gave the last.

58
00:02:38,780 --> 00:02:39,630
It is not as you don't.

59
00:02:39,650 --> 00:02:40,880
We will not do plus one.

60
00:02:41,150 --> 00:02:43,930
So we'll simply return small answer.

61
00:02:45,050 --> 00:02:45,380
OK.

62
00:02:45,920 --> 00:02:47,350
And the latitude is it.

63
00:02:47,360 --> 00:02:49,380
We will dance Malaysia plus 1.

64
00:02:49,400 --> 00:02:51,340
Let's see how this code will work.

65
00:02:51,410 --> 00:02:52,060
So.

66
00:02:52,340 --> 00:02:53,980
OK so 1 0 2 2 0.

67
00:02:53,990 --> 00:02:55,220
Take this example only.

68
00:02:55,820 --> 00:03:00,390
So I have this example 1 0 3 2 1 0.

69
00:03:00,560 --> 00:03:03,210
So make the Parliament a smaller part.

70
00:03:03,250 --> 00:03:04,820
With qualification on this part.

71
00:03:05,400 --> 00:03:05,980
OK.

72
00:03:06,060 --> 00:03:10,340
So this will become 1 0 3 2.

73
00:03:10,440 --> 00:03:14,360
Then again call that equation a smaller part.

74
00:03:14,390 --> 00:03:16,710
So this will become 1 0 3.

75
00:03:17,090 --> 00:03:18,980
Again call that equation a smaller part.

76
00:03:19,010 --> 00:03:23,150
So this will become 10 again called that equation on the smaller part.

77
00:03:23,750 --> 00:03:27,650
So this will become one again called education the smaller part.

78
00:03:27,920 --> 00:03:29,470
So this part is 0.

79
00:03:29,510 --> 00:03:31,290
So I'm calling 1 0.

80
00:03:31,340 --> 00:03:35,360
Now this will become our base case.

81
00:03:35,370 --> 00:03:36,180
So what will happen.

82
00:03:36,180 --> 00:03:38,900
I will return 0 okay.

83
00:03:38,920 --> 00:03:41,510
Now we will check the last digit losses of this one.

84
00:03:41,560 --> 00:03:44,260
So simpler than the smaller answer.

85
00:03:44,270 --> 00:03:45,480
We will check the last digit.

86
00:03:45,490 --> 00:03:46,710
Another last digit is zero.

87
00:03:46,720 --> 00:03:50,170
So what do we do smaller on the set plus 1.

88
00:03:50,170 --> 00:03:52,720
So we will return 0 plus 1 which is 1.

89
00:03:52,720 --> 00:03:53,910
Now check the last digit.

90
00:03:53,920 --> 00:03:55,550
It is not zero.

91
00:03:55,600 --> 00:03:59,110
So it is simpler than the smaller answer which is one only.

92
00:03:59,110 --> 00:04:01,470
Okay now check the last budget which is 2.

93
00:04:01,740 --> 00:04:05,190
So we will simply write down the smaller answer.

94
00:04:05,200 --> 00:04:06,400
Now check the last digit.

95
00:04:06,430 --> 00:04:07,330
So this is zero.

96
00:04:07,480 --> 00:04:08,630
So we will add plus 1.

97
00:04:08,980 --> 00:04:12,660
So this will become one plus one which is 2 so too is our answer.

98
00:04:12,710 --> 00:04:13,220
Okay.

99
00:04:13,270 --> 00:04:15,130
So that's all very simple good.

100
00:04:15,130 --> 00:04:15,750
Okay.

101
00:04:15,910 --> 00:04:18,260
Now let us write the code.

102
00:04:18,550 --> 00:04:20,660
So what was the return type.

103
00:04:20,710 --> 00:04:23,180
We all know that you don't type will be integer.

104
00:04:23,440 --> 00:04:28,160
Let's say the name of the function is count zeros what it will take.

105
00:04:28,160 --> 00:04:29,130
It will take a number.

106
00:04:29,130 --> 00:04:32,790
And this argument again two simple steps.

107
00:04:33,000 --> 00:04:34,400
First the base case.

108
00:04:34,410 --> 00:04:35,900
Now the base case is very simple.

109
00:04:35,910 --> 00:04:38,580
If the value of an 0.

110
00:04:38,610 --> 00:04:39,630
We will return 0

111
00:04:42,610 --> 00:04:43,530
if the value.

112
00:04:43,540 --> 00:04:50,230
Now it's time for the recursive case so what is a recursive case.

113
00:04:50,230 --> 00:04:53,240
So the recursive case what we talked about.

114
00:04:53,260 --> 00:04:55,750
Okay so what is a recursive case.

115
00:04:55,750 --> 00:04:57,490
So small answer

116
00:05:00,930 --> 00:05:05,520
calculate the zeros present in the number and by then.

117
00:05:05,780 --> 00:05:06,080
Okay.

118
00:05:06,110 --> 00:05:12,320
So we are concluding the Zulus peasant dinner then a mutt and Martin and then our calculation part

119
00:05:15,240 --> 00:05:16,290
so what is that calculation.

120
00:05:16,280 --> 00:05:19,940
But we will use a friend and so if the last digit.

121
00:05:19,960 --> 00:05:22,560
OK so first of all let's calculate the last digit

122
00:05:25,470 --> 00:05:32,940
so the last digit is and more than so the last digit as and more ten.

123
00:05:33,060 --> 00:05:34,420
Now we will check.

124
00:05:34,500 --> 00:05:40,280
So if the last digit equals equals zero what do we do.

125
00:05:40,280 --> 00:05:50,010
So our answer will become we will have done one plus small onset otherwise in the else part we will

126
00:05:50,010 --> 00:05:52,330
simply write down our smaller answer.

127
00:05:52,440 --> 00:05:52,910
Okay.

128
00:05:55,850 --> 00:05:59,850
It will seem better than our small my answer okay.

129
00:06:00,020 --> 00:06:03,120
So this is very simple called.

130
00:06:03,310 --> 00:06:05,050
Now let's call this function

131
00:06:11,410 --> 00:06:14,710
so let's say the value is 1 0 3 2 0 only.

132
00:06:14,920 --> 00:06:16,840
Okay.

133
00:06:17,140 --> 00:06:21,130
Okay so let's make Okay 1 0 2 2 0 only.

134
00:06:21,130 --> 00:06:22,380
Okay.

135
00:06:22,750 --> 00:06:30,150
Now let's turn our file sought out put this coming out to be true because there are two zeros present

136
00:06:30,370 --> 00:06:30,850
and then.

137
00:06:30,880 --> 00:06:34,230
But okay now let's.

138
00:06:34,290 --> 00:06:38,700
Now we were bright in our code and we will make the diagram.

139
00:06:38,700 --> 00:06:43,260
Okay so one more thing in this question the value of and will be good denoted close to one.

140
00:06:43,260 --> 00:06:45,240
Okay so this is given.

141
00:06:45,270 --> 00:06:45,600
Okay.

142
00:06:45,630 --> 00:06:50,620
This is then put this is the constraint the value of N will be given will be good in order to win.

143
00:06:50,820 --> 00:06:51,230
Okay.

144
00:06:51,390 --> 00:06:52,640
Now let's say I didn't a code.

145
00:06:53,490 --> 00:06:55,560
So let's take a different example.

146
00:06:56,060 --> 00:07:03,130
Okay let's say the value is 2 0 0 2 Let's say the number is closer as it would do.

147
00:07:03,130 --> 00:07:04,740
So our answer should be 2.

148
00:07:04,780 --> 00:07:05,270
Okay.

149
00:07:06,400 --> 00:07:07,270
Now what will happen.

150
00:07:07,300 --> 00:07:09,610
So this is not close to zero.

151
00:07:09,610 --> 00:07:10,470
So we will.

152
00:07:10,720 --> 00:07:13,260
We will call this function the smaller part.

153
00:07:13,300 --> 00:07:16,630
So I am calling this function on 200.

154
00:07:16,660 --> 00:07:19,310
This function will wait at line number 10.

155
00:07:19,450 --> 00:07:21,490
Again this function will be returned line number 10.

156
00:07:21,520 --> 00:07:26,220
We will call in 20 dysfunctional wait at line number 10.

157
00:07:26,230 --> 00:07:30,150
We will call on to this function will wait at line number 10.

158
00:07:30,310 --> 00:07:32,170
It will call on 0.

159
00:07:32,170 --> 00:07:35,090
Okay so we will hit the base case here okay.

160
00:07:35,110 --> 00:07:39,740
We are getting the base case it is attending 0 it is bending 0.

161
00:07:39,750 --> 00:07:42,390
So our small answer is 0.

162
00:07:42,660 --> 00:07:44,100
And then the last digit.

163
00:07:44,190 --> 00:07:44,930
And Martin.

164
00:07:44,940 --> 00:07:48,120
So the last digit is two more 10 which is 2.

165
00:07:48,120 --> 00:07:50,180
Okay so 2 is not too close to zero.

166
00:07:50,190 --> 00:07:52,140
So a little simpler than the small answer.

167
00:07:52,140 --> 00:07:53,680
So we will simply order 10 0.

168
00:07:53,940 --> 00:07:54,790
Okay.

169
00:07:54,780 --> 00:07:58,880
West Ambler Dunning zero cell is my line set is zero.

170
00:07:58,950 --> 00:08:01,860
Then again we will conclude the last digit.

171
00:08:01,920 --> 00:08:02,260
Okay.

172
00:08:02,280 --> 00:08:04,480
This function always waiting outside Number 10.

173
00:08:04,500 --> 00:08:06,140
Now it will come to light number 13.

174
00:08:06,150 --> 00:08:08,800
We will conclude the last digit and Martin.

175
00:08:08,860 --> 00:08:10,490
So a lot of it is zero.

176
00:08:10,650 --> 00:08:14,640
If the last digit is we don't we are returning 1 plus small answer.

177
00:08:14,640 --> 00:08:17,140
So 0 plus 1.

178
00:08:17,420 --> 00:08:20,550
Sylvia Dunning when now the spotlight sort of becomes human.

179
00:08:20,850 --> 00:08:24,870
Okay again we will check the last digit losses to zero.

180
00:08:25,380 --> 00:08:27,020
So we will return when bless.

181
00:08:27,060 --> 00:08:29,020
Small answer which is 2.

182
00:08:29,060 --> 00:08:29,290
Okay.

183
00:08:29,310 --> 00:08:31,450
So our small answer is 2.

184
00:08:31,710 --> 00:08:34,650
Now the last digit is 2 2 is not close to zero.

185
00:08:34,680 --> 00:08:36,650
So will simpler than the small answer.

186
00:08:36,680 --> 00:08:38,790
So will simply return to.

187
00:08:38,910 --> 00:08:39,180
Okay.

188
00:08:39,180 --> 00:08:40,590
And this is our answer.

189
00:08:40,800 --> 00:08:41,300
Okay.

190
00:08:41,400 --> 00:08:43,590
So I will call it is working fine.

191
00:08:43,590 --> 00:08:44,100
Okay.

192
00:08:44,160 --> 00:08:46,370
So I hope you understand this problem also.

193
00:08:46,770 --> 00:08:47,150
Okay.

194
00:08:47,190 --> 00:08:48,690
If you have any doubt you can ask me

195
00:08:55,390 --> 00:08:57,220
okay so I hope you understand this problem.

196
00:08:57,220 --> 00:08:59,510
So if you have any doubt you can definitely ask me.

197
00:08:59,580 --> 00:08:59,990
Okay.

198
00:09:00,160 --> 00:09:00,540
Thank you.
