Hello everyone.
Welcome to the session.
So today we will solve one more problem with the help of the occasion.
So the name of the problem is currency it.
OK so what is the problem.
So the problem is very simple given a number let's say the number is 1 0 3 2 0.
So we have to calculate how many zeros at present.
So in this case our output will be two.
Okay.
Because there are two zeros okay.
Now let's take one more example of the value of and this let's say 123.
Then output will be zero because there are no 0 present.
OK.
So I hope you've got the problem we just have to count the number of zeros present inside the number.
OK now how we can solve this problem.
So basically what we have to do we will go to each and every digit.
We will go to each and every digit.
And if the digit is 0 we will do our answer plus plus.
Okay.
So this was the approach of when we are using for loop of divine loop.
OK.
Now we will use a similar approach if we are using recursion also.
So what we will do.
So given that the Model T the number is 1 0 2 2 0 only.
So what I will do.
So I will tell that equation.
Give me how many zeros at present in this Malone.
So the equation will give me that answer for this is one.
Okay.
Because there are 1 0 present then what we will do we will check the last digit.
OK.
We will check this last digit OK.
So this last digit is it.
So what do we do.
We will do one plus one.
OK.
Since the last budget is it what we will do plus one.
So the answer will become to OK.
So this is how this code will work if we want to.
So this will be now.
This is the function count zeros.
It will take a number and as argument.
What I will do.
So this cone zeros function concludes the count convert the number of zeros present inside the number.
And so I will give the smaller input.
So it will give me how many zeros at present in the number.
And by 10.
So this is basically and by 10 OK.
So this will be our problem.
This will be done stuff with a similar problem.
And then we will check the last digit.
OK so we will check if the last digit in this case it is 0 here.
So if the last digit is 0 what we will do we will add plus 1 to our answer.
So this was our smaller answer.
So what do we do.
We will lose more Laron said plus plus or we can write a small lines plus one in the each part.
You will simply there done smaller answer or gave the last.
It is not as you don't.
We will not do plus one.
So we'll simply return small answer.
OK.
And the latitude is it.
We will dance Malaysia plus 1.
Let's see how this code will work.
So.
OK so 1 0 2 2 0.
Take this example only.
So I have this example 1 0 3 2 1 0.
So make the Parliament a smaller part.
With qualification on this part.
OK.
So this will become 1 0 3 2.
Then again call that equation a smaller part.
So this will become 1 0 3.
Again call that equation a smaller part.
So this will become 10 again called that equation on the smaller part.
So this will become one again called education the smaller part.
So this part is 0.
So I'm calling 1 0.
Now this will become our base case.
So what will happen.
I will return 0 okay.
Now we will check the last digit losses of this one.
So simpler than the smaller answer.
We will check the last digit.
Another last digit is zero.
So what do we do smaller on the set plus 1.
So we will return 0 plus 1 which is 1.
Now check the last digit.
It is not zero.
So it is simpler than the smaller answer which is one only.
Okay now check the last budget which is 2.
So we will simply write down the smaller answer.
Now check the last digit.
So this is zero.
So we will add plus 1.
So this will become one plus one which is 2 so too is our answer.
Okay.
So that's all very simple good.
Okay.
Now let us write the code.
So what was the return type.
We all know that you don't type will be integer.
Let's say the name of the function is count zeros what it will take.
It will take a number.
And this argument again two simple steps.
First the base case.
Now the base case is very simple.
If the value of an 0.
We will return 0
if the value.
Now it's time for the recursive case so what is a recursive case.
So the recursive case what we talked about.
Okay so what is a recursive case.
So small answer
calculate the zeros present in the number and by then.
Okay.
So we are concluding the Zulus peasant dinner then a mutt and Martin and then our calculation part
so what is that calculation.
But we will use a friend and so if the last digit.
OK so first of all let's calculate the last digit
so the last digit is and more than so the last digit as and more ten.
Now we will check.
So if the last digit equals equals zero what do we do.
So our answer will become we will have done one plus small onset otherwise in the else part we will
simply write down our smaller answer.
Okay.
It will seem better than our small my answer okay.
So this is very simple called.
Now let's call this function
so let's say the value is 1 0 3 2 0 only.
Okay.
Okay so let's make Okay 1 0 2 2 0 only.
Okay.
Now let's turn our file sought out put this coming out to be true because there are two zeros present
and then.
But okay now let's.
Now we were bright in our code and we will make the diagram.
Okay so one more thing in this question the value of and will be good denoted close to one.
Okay so this is given.
Okay.
This is then put this is the constraint the value of N will be given will be good in order to win.
Okay.
Now let's say I didn't a code.
So let's take a different example.
Okay let's say the value is 2 0 0 2 Let's say the number is closer as it would do.
So our answer should be 2.
Okay.
Now what will happen.
So this is not close to zero.
So we will.
We will call this function the smaller part.
So I am calling this function on 200.
This function will wait at line number 10.
Again this function will be returned line number 10.
We will call in 20 dysfunctional wait at line number 10.
We will call on to this function will wait at line number 10.
It will call on 0.
Okay so we will hit the base case here okay.
We are getting the base case it is attending 0 it is bending 0.
So our small answer is 0.
And then the last digit.
And Martin.
So the last digit is two more 10 which is 2.
Okay so 2 is not too close to zero.
So a little simpler than the small answer.
So we will simply order 10 0.
Okay.
West Ambler Dunning zero cell is my line set is zero.
Then again we will conclude the last digit.
Okay.
This function always waiting outside Number 10.
Now it will come to light number 13.
We will conclude the last digit and Martin.
So a lot of it is zero.
If the last digit is we don't we are returning 1 plus small answer.
So 0 plus 1.
Sylvia Dunning when now the spotlight sort of becomes human.
Okay again we will check the last digit losses to zero.
So we will return when bless.
Small answer which is 2.
Okay.
So our small answer is 2.
Now the last digit is 2 2 is not close to zero.
So will simpler than the small answer.
So will simply return to.
Okay.
And this is our answer.
Okay.
So I will call it is working fine.
Okay.
So I hope you understand this problem also.
Okay.
If you have any doubt you can ask me
okay so I hope you understand this problem.
So if you have any doubt you can definitely ask me.
Okay.
Thank you.