Hey, guys, what's up?
So today we are going to solve one more interesting problem on Eddie.
So the problem is very easy.
We have to reverse the Eddie.
Reveals the ending.
So, for example, if my is, let's say, one, four, five and seven, so my ad, it should become
seven, five, four and one.
OK.
So we have to reverse these at a in the previous problem.
The problem was we have to print the ad in reverse order.
So we were printing that in reverse order.
So that was the reverse print.
But this problem is different.
And this problem, I have to reverse the ad.
OK, so my new ad a little bit this.
For example, if my hat is one, two, three, four and five.
So my array should become.
Five, four, three, two and one.
So in this problem, we are not doing printing.
We are in fact reversing the error.
So how we can solve this problem.
So the problem.
So the algorithm for this problem is very easy.
So what we have to do is suppose.
So let us take small example.
So suppose my ad is.
Let's say there are six elements in the area, so two, four, five, one.
Let's see, my elements are six and seven, so then let's say there are six elements in my area.
So what I will do, I will take two pointers.
So this is my start pointer.
And this is my.
And pointer.
OK.
So initially Starbase zero and is.
And minus one.
What I really do.
I will swap.
I will swab.
Start.
And so you will be slapped with seven.
So here will come here.
Seven will come.
Then what I will do, I will increment as so as will come here and and I will come here.
I will decrement E!
So start bless plus and minus minus.
Then again, I will do the swapping.
So formally we sabata with the six.
Then again, Start will come here and will come here.
So five will be served with one.
So five is so out of it.
When then what will happen now?
Start will come here because we are doing start plus plus and and will come here.
So this is my end.
Now what happened is start becomes greater then.
And so if this is the condition where we have to do.
Break.
Our problem is.
Or what.
And our new Addy's seven.
Then six.
Then one.
Then five.
Then four.
And then two.
So this is my new.
And my previous said it was two, four, five, one, six and seven.
So this was way out already.
And this is and this is my updated area, so you can compare the additive also featured that.
OK.
So this we have to do.
So the logic is very simple.
So I've already made a final reverse, I not see.
First, let us take input and then.
That doesn't make any.
Now we have to take.
And we lose as input.
Down, I
know that reverse logic was very simple.
Where do we have to do?
We have to date 2.0 start is initially zero and is initially and minus one.
So my start is initially zero and and is initially at last index.
So how many times I have to perform swopping while my start while my start is less than or equal to.
And so this is the condition.
I have to swab.
So swab it off.
Start.
It off.
And so we are doing scrapping.
So after stepping would have to do start was Implementor and and was DiClemente to start plus plus and
minus minus.
OK.
So then with each line number 22, I would add it will be in reverse order.
OK, so this is all that we have to do.
Now let us print.
Eddie so see you out after.
He was so after he was.
This is my Eddie.
So forward and I equals zero.
I lost him and I bless bliss.
See out of I.
And similarly, her dad spent before doing he was.
So before.
Before reverse.
Now, let us test our program.
Suppose there are four elements and the elements are.
Five, one, two and three.
OK, so there is an error.
So what happened here is.
Before reverse.
So and and CNN equals zero less than an.
Saying I before.
I close, you know, I listed nine plus plus.
So what happened wrong here?
Start.
So first to bend.
Now let us not go well.
There are two elementally one and two.
Sixteen.
So what is happening here?
We created.
I quote to a listing in.
Shapelessness seen I.
Okay, so it was a sit in I.
And it should have been seen if I.
OK, so this was Deanna.
Now, there are plenty of water elements and elements are two six, one in four.
So let's bring in one line.
Now, let's test.
So there are four elements and elements are two, six, one and full.
So before reverse, this is my element.
And after reverse, this is out of my element.
So the defense we're doing this probably on the last order is that.
And this problem, we are reversing the.
OK.
We are printing from left to right.
In the previous problem, we were printing from right to left.
So let us tested for one more time.
Number of elements are five and the elements are one five, nine, three and two.
So this is before reverse.
And this is after reelers.
OK.
So my code is working.
Hundred percent.
Correct.
So if you have any doubt, feel free to ask.
So this is it for this video.
Thank you.