Hi, everyone.
So in this video, we are going to solve this question, remove consecutive duplicates.
So if this is my string A, B, B, B, C, D, D.
So if this is my string, I need to remove the consecutive duplicates.
So is present consecutively and duplicate.
OK, so consecutive and duplicates.
So we will take only one.
So two is at present.
I will take only one, two, three B's at present, but I will take only one six percent, only one
time.
So C D present twice.
So I will take only one and is present.
So.
So if this is my string A, B, C, Beedie so what will be the output.
So is present E then B's B's Alonzo B C alone C B alone B and these alone.
Sordi So no changes and this string and here we need to take only one.
OK, so if it is presented multiple times we will take only one.
So B is present three times so we will take only one B so I hope you understood the question so we can
solve this question easily with the help of all available since we are learning recursion.
So let's use recursion.
So indication how we can solve this question.
So again, this is my car today.
I will work on this small problem and I will give recursion, this big problem to solve.
So let's see.
So first of all, what I will do this is Rick Perry.
So I will check the character and the first character.
So if they are equal, I to do something in the ultimate.
So if they are not equal, see, there can be two situations, 010 first character, they are equal
or they are not equal.
So if they are not equal, if they are not equality, the Springers be in.
So in this case, B and they are not equal.
So B, they are not equal.
So in that case, what I will do, I will call that equation on this area.
I will call let you guys in on this area because I have done my small amount of work and will do big
amount of work.
So I will call that equation.
So I will call Dacogen and that is input plus one.
Simple, I will let you guys in on this area and this area is basically this is input and this is input
plus one, so I will give input plus one.
Now, if the situation.
If 08 in the first, they are saying so basically.
I have a and then I have BCD and something, so if the first two characters are same, so I told you
we need only one character, we need only one.
So what I will do, I will shift all the characters towards left, just like the previous problem.
I will shift all the characters towards left.
So let's take one example.
So I have this A and then I have B, C, D, D and B, and then I have done so.
In this problem you can see the easy route and the first character the same.
So zero and the first character, if they are same, shift all the characters towards left, just like
the previous problem, the shift, all the characters towards left.
So this will be then B, then C, then D, B so we will shift that also.
So then null and then so this will be our new string.
This will be our new crit bearing.
And then what we need to do, we will call on this area, but we will give input.
So input will remain the same.
So this was in Putera, I will call it, because you're not in Portelli.
So after shifting all the elements towards left, I will call that equation on in Proterra.
So I will call that equation input and not input plus one.
So I hope you understood the question.
So now let's write the code.
So writing the code is very simple.
They are able to function.
It would be void.
I will not return anything.
Let's say the name of the function is remove consecutive duplicate.
So it will take correct barriers and put.
This case is very simple, if my heart is empty, so if that is empty, so if in Port of Zero at of
the original.
So in that case, there is nothing to be deleted, so we will simply have done we will not do anything,
we will simply have done.
So now in the off part, so if the first two characters are different, so if in pataphysical.
And in 2001.
If they are different, if the first two characters are different.
Then I will simply call precaution, so if the first two characters.
So if the zeroth character and the first character, if they are different, if the first character
they are different, then what I will do.
So I have worked on this small problem I have compared to the character of the first group.
But now it's time to call dedication on this idea.
So I will call a question and the question will remove all the duplicates, all and regulatory.
So let's call that a corporate entity with a function.
So remove consecutive duplicate.
And I will do I will pass the idea and put one now in the sales part, the first to criticize him.
So if the first to criticize him, then it's very easy, then I have B, B, C, D.
So if the first two characters are slim, indeed they are slim, then they need to do I need to shift
all the characters towards the left?
So shift all the characters towards left, I have none here, so and so two times A, then B, so B,
B, then suddenly C and B and will also shift null, null.
And we have none at the last also.
So this will be our new area.
This will be our new input area.
And we will call Dacogen on this input only.
OK, so now you can see it is present two times again, experimental times again.
So again, what do will also shift?
So it will become a shift, all the element towards left.
So then we then B, then C, then D, then null then.
And so this will be our new and this will be the input area.
So I will again call the location on this area.
So this time, this time the first two elements are different.
So I will call the equation smaller.
I will call the equation smaller B, B, C, D, and so there's no need to write multiple times because
when the less efficient one will do the work.
So no need to write down multiple times.
So now I will call the equation on this.
So first, two elements are same again shifting and so on.
So we need to shift.
And I write the code for shifting in our previous video, so I equals zero.
And Partovi is not close to only.
I placeless so in Partovi.
Is it was to and Partovi plus one.
So after shifting the element we need to call the election, so do I need to call the equation in Pataudi?
And I think our function will work.
So let's call the function here, see, I am printing the lint and I'm bringing the character ready.
Now, let's call the function remote control to duplicate.
I will pass the input today.
So after removing the consecutive duplicates, I am printing the list again and I am printing the correct
that again.
So I think we did everything fine.
So let's test our function.
So let's say A, B, B, B, C, D, D, E, and basically the total number of characters is nine.
So you can see eight percent two times, but in the output is president only one time.
So B was president twice, but vice president only once see only one.
So when the president was president two times, but now it is only one time.
So he alone, alone and Lelantos five.
So basically our function is working.
So let's test it one more time.
So let's say the importance, ay, ay, ay, and then I have B, C, B, B, C, D and easy.
So let's test whether our output is right or wrong.
So it was present multiple times, but now is present only once.
So then it was busy, so busy then B was present twice.
So be present only once, c once.
Even the one time, the one time it was present twice.
But now it's present only once and the length is seven and for this area discredited Atlantis 14.
So basically our function is working.
So this is it from this video.
I will see you the next one.
Thank you.