Hello, everyone, welcome to the station.
So today we will solve one more problem with the help of regulation.
So the name of the problem is currency rules.
OK, so what is the problem?
So the problem is very simple, given a no, let's say the number is one zero three two zero.
So we have to calculate how many zeros are present.
So in this case, our output will be to OK, because there are two zeros.
OK, now let's take one more example of the Valley of and let's say 123, then the output will be zero
because there are no zero present.
OK, so I hope you 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 zero, we will do our answer.
Plus, plus.
OK, so this was the approach that we are using for loop or divine loop.
OK, now we will use a similar approach if we are using regression also.
So what we will do so given the number, let's say the number is one zero three two zero only.
So what I will do so.
I will tell that equation, give me how many zeros are present in this modern world, so Dacogen will
give me that answer for this is one, OK, because they are the ones you represent, then what we will
do, we will check the last date, OK?
We will check this last digit.
OK, so this last digit is zero.
So what we will do, we will do one plus one.
OK, since the last year to zero, we will do plus one.
So the answer will become to.
OK, so this is how this court will work if you want to.
So this will be.
Now, this is the function and zeroes, it will take a number and an argument what I will do.
So this Consuelo's function calculates the count, the number of zeros present inside the number.
And so I will give the smaller input.
So it will give me how many zeros are present in the number and by ten.
So this is basically.
And Martin.
OK, so this will be our problem.
This will be done for a similar problem and then we will check the last digit.
OK, so I will check if the last digit in this case, it is zero here.
So if the last digit is zero, what we will do, we will add plus one to our answer.
So this was our smaller answer.
So what we will do, we will do smaller answered plus plus.
Or we can write a smaller answer plus one.
In the last part you will simply return a smaller answer.
OK, if the latter it is not, you don't we will not do plus one, so we will simply return small answer.
OK, and later the president, we will dance a plus one.
Let's see how this code will work.
So, OK, so one zero three two zero.
Let's take this example only.
So I have this example one zero three two one zero.
So big the problem, the smaller part with qualification on this part.
OK, so.
This will become one 032 then again.
You a smaller part, so this will become one zero three again, colocation, a smaller part, so this
will become then again called education on the smaller part.
So this will become one again, called education, the smaller part.
So this part is zero.
So I'm calling on zero now.
This will become our base case.
So what will happen, I will return zero.
OK, now we will check the last digit losses of this one, so simply return the smaller answer, we
will check the last digit.
The last digit is zero.
So what we will do a smaller answer plus one.
So we will return zero plus one, which is one.
Now, check the last digit.
It is not zero.
So I will simply return this my answer, which is one only.
OK, now check the last budget, which is two.
So we will simply return the smaller answer.
Now check the last digit.
So this is zero.
So we will add plus one.
So this will become one plus one which is.
So too is our answer.
OK, so that's all very simple.
OK, now let us write the code.
So what will the return type we all know that will be integer.
Let's say the name of the function is count zeros.
What it will take, it will take a number and as argument again, three simple steps.
First, the best case, not now the base case is very simple.
If the value of and zero, we will return zero.
If the value now it's time for the recursive case.
So what does a recursive case, so the recursive case, what we talked about.
OK, so what is the recursive case?
So small answer.
Calculate the zeros present in the number.
And by 10:00, OK.
So we are calculating the zero spending then and then and then our calculation part.
So what is the calculation part we will use if handled 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 two days and more than now, we will check.
So if the last digit equals equals zero.
What we will do, so our answer will become.
We will return one plus small answer.
Otherwise, in that last part, we will simply return our smaller answer.
OK.
It will simply tear down our small lanser.
OK, so this is very simple called.
Now, let's call this function.
So let's say the value is one zero three two zero only.
OK.
OK, so let's make one zero two zero only.
OK, now let's turn our file.
So I thought this coming out to be true because there are two groups present in the number.
OK, now let's now we will try it in our court and we will make the diagram.
OK, so one more thing in this question.
The value of and will be good in order to win.
OK, so this is given OK, this is the end.
But this is the constraint.
The value of and will be given will be greater than or equal to one.
OK, now let's bring our code.
So let's take a different example.
OK, let's say the value is two zero zero two.
Let's say the number is 002, so our answer should be two.
OK.
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 a third line number.
Then we will call on 20.
Dysfunctional with a headline number 10, we will call on two dysfunctional with a headline number 10,
it will call on zero.
OK, so we will hit the basics here.
OK, we are hitting the best.
It is returning zero.
It is returning zero to our small answer is zero and then the last digit and more then so the last budget
is two more 10, which is two.
OK, so two is not close to zero.
So we'll simply return the small answer.
So we'll simply return zero.
OK, we are simply returning zero.
My answer is zero.
Then again, we will calculate the last digit.
OK, dysfunctional waiting hard line number 10.
Now it will come to line number 13 will calculate the last digit and then so that it is zero if the
last digit is zero.
We are returning one plus smart answer.
So zero plus one.
So we are returning.
Well now the answer becomes one.
OK, again, we will check the last digit losses at a zero.
So we will return when plus small answer which is to OK, so our small answer is to know the last digit
as to who is not close to zero.
So it will simply return the small answer.
So will simply return to OK.
And this is our answer.
OK, so it is working fine.
OK, so I hope you understood this problem also.
OK, if you have any doubt you can ask me.
OK, so I hope you understand this problem, so if you have any doubt, you can definitely ask me,
OK?
Thank you.