Hallowed event.
So in this video we are going to decide one question reverse a string.
So for example if the input is Hallowell so hello then space and then word so after reversing the string
where do the reverse of this thing so D and R O W then space O N and E H.
So far finding out that it was just start the string from the back.
So be an odd or w the N or W then space so space then o an edge.
So O double l e edge.
So what do you have to do so given input string.
Give it a posting and you have to convert the input string and doing that he was of the string so that
is the meaning of the ocean.
Reverse the string.
Now let's take one more example.
So suppose the input string is ABC.
ABC then what you have to do so you will convert then would sing to which city votes so it reverses
D C B and A.
So I hope you understood the question.
So now let's take one.
One more example so suppose the input string is a b c b e f so how does this string will be stored inside
the correct baddy.
It does very with a then B then C then D then E then F and add then obviously you will have the null
corrected.
Now how you can dig the reverse of the string so the procedure is going to be very very simple.
It is very obvious that you do not have to do anything with the null correct and incorrect is going
to be present at the last position.
So that is very obvious.
Now what does that a lot of the string.
So this is f then I F E so B C B and A.
So this is the output and not let us discuss where this what should be our approach.
So what I will do to obtain that it was the procedure is very simple.
So the first and the last correct.
So F will come here even come here.
Now step the second and the last second will get better.
So even come here and be welcome here and similarly Gib doing this so C and D will get SAB.
So Deven go there and C will go mad and you can match so this is FCB CBE f EDI CB.
So that is the approach that we are going to follow.
So what is the approach.
The approach is going to be very very simple.
I will take two point.
So this is my start point.
This is my end point to what I will do.
I will swap my start point with the end appointed.
So start point I will move in this direction and point that it will move in this direction.
So I will loose start plus plus I will do and minus minus.
And we have to keep doing this.
How many times so vital the start point does less than and point the you will have to perform these
steps simple.
So what do we lose so this start point.
So E is going to subdivide the F so F will come here and even come here.
Then you will loose start plus MSO start will come here.
So this is my new start and this is my new end.
So be and even get swept so you will lose start.
Plus plus you will do and minus minus.
So this is my new start.
This is my new end so you will swap CND then you will do start plus plus.
So this will become start and you will do it minus minus.
So this will become and and now the condition will become void because now the start becomes good then
end.
So at this condition you will stop very very simple logic so if you want I can take one more example.
For example ABC.
So what I can do this is my start point but this is my and appointed swept starting in.
So after the sweeping these are going to come here and is going to come here.
Now start plus plus and minus minus.
So this is your new start.
This is your new end and demoed this or in again we will do this mapping.
So after this wrapping B and C will get swept so C will come here and B will come here and again you
will update to a start and end.
So start plus plus and minus minus.
So this will become your start and this will become your end.
And at this point you will stop.
So we have to do the work vital My start is less than and very very simple.
So let us write the code and then we will write a have a called
So where do letter turn type so I will not written anything I will just do that in just inside of my
creek bed and only.
And let's say the name of the function is reverse what it will take it will take a character that is
input and what we have to do I have to take two pointers.
So I have take the first pointer.
So first point let us take that test name it start.
So start the loop as it Zito and we loop as it did last year index.
And in order to find out the last 16 I can use the function and so I would call the function Lent.
I will give input as I have given poor daddy minus one.
So this would be good and index.
So let me check.
So this is index 0.
1 2 3 4 and 5.
So it is very obvious that initially my start will be zero.
It is very obvious I want to find out.
And so if you will apply the lend function.
So what is the lent lent us 1 2 3 4 5 and 6.
So Lent is actually 6 and the index of 5 and then takes off and is actually 5.
So that means the index is actually lent minus 1 the index is actually lent to minus 1.
You can consider the above example also so in this example.
This was my start.
So we do not have any confusion I would start start will be initially zero very obvious what is the
Lent so Lent is actually filled and this is my end so end is actually.
So this is index 0 and X1 and X2 in our next 3.
So I can see that my end is actually lent minus 1 I can see my end is actually the Lent minus 1.
So I'm using the Lent function so we have all read and the code for the Lent function in our previous
lessons and then what we have to do we have to do swapping and the condition is very simple VI start
is list and end you will loose wrapping so I have and will function step in C++.
So I want to sep start and end so Sep start
and end so I'm swapping and didn't start plus plus and minus minus.
Very very simple and the return type of the function is wide so we do not have to do anything and here
what we would what we will do.
I will call the function so see out
so Firstly let us call the function to the name of the function is reverse
then add the function is it was I am passing and put
and after passing the input let s spent reversed.
String order can't be reversed.
Correct Daddy name.
And we know that the daddy are past biodefense.
So whatever you are doing changes with the correct in dysfunction function it will get reflected in
Maine also.
I'm repeating myself.
We know that the ads are passed by at a friend's soon so passed by the office.
So whatever changes you are doing with the ad inside the reverse function it is going to be reflected
inside.
Also so no let us based our program
so.
Okay.
So what is happening here at this planet will say the.
I do not know what is lent because Lent is defined below the reverse function so that this line compiler
doesn't know what is lent.
So what we have to do is just copy.
Sorry just just cut and paste above.
So we have to write the code of the land above.
I'm repeating myself this at this link compiler doesn't know what this Lent function because the Lent
function was written after the release function after this line.
So that's why it will give you error that it doesn't know what is lent.
So you have to write lend function before and obviously let us change this one also.
So it seemed a the guideline name and a hundred.
So that means I can let me start delimiter by default.
This new line now let us test our program
so this is reverse.
Okay so the name of the ad is actually name the name of the ad is actually name.
I want to reverse ABC so your string is ABC and the reverse a string is CB.
Now let us give a b c v e f so your string is a b c d e f and after that it was in it will become F
E D CBE.
Now let us test one more time so this time it does give.
Hello world.
So hello space world.
So this is your input string Hello World and this is you reverse the string DL out of the blue space
0 and then each you can give multiple spaces also saying don't get land can handle multiple spaces also
for example hello then space space space and then word.
So this is your input string and after the reversing after the reverse function this is yet output string.
This is your.
It was this string so other it was function called is looking perfectly fine and the logic is very simple
take two pointer one at the beginning one at the end keep slapping them start will move in default word
not action and pointer will move in the backward direction and you have to keep doing this work while
you start is actually list and end very very simple.
So if you have any doubt in discussion you can definitely ask me I will do the next one.
Bye bye.