 Hi this is Christian again this time we're going to do another in-place algorithm using strings. Now the examples we've been doing so far are just given numbers. Now if you deal with strings it's a little bit different because in Java strings are immutable that means you can't really just replace a character. So no matter what you still have to recreate a new string anyway but I'm going to show you how you can do that using just in-place algorithm. Okay so a string will work just like how we did earlier using this in-place with a temp variable like this that will be fine no problem. So for example if I go back and change all these here and let's create a new a string variable here we'll call it ststr has some origin here and I'm going to go back and collapse these so I have some more space more room and we can use things like eight at chip string and then eat okay five we enough if it pass that over to the print function let's print them out before and after and we'll be use that in-place temp just to show that it does work okay so if I can see that now going to run you should print out those words in reverse order as you can see over there okay so this time I'm going to do something similar to these two operations using just pure in-place okay so let's go back and create another function here and we collapse these so it's not too distracting let the static oops and place str we're passing a string array and then let's see how we do this so what do we do this time the idea or the approach I'm going to take is really I'm going to combine or join two strings together and put it into the first lab so will be something like this let me if I can annotate this quickly here again my tablet is not really nice I'm not really good at it so I apologize but let's say I want to you know swap this position which is the zero position with the last position of the fourth index okay so first n of one n of zero n of the zero position will be I basically joined the word eight together with the word eat right so I get the position add them up you get that string okay so now n of the last position how do I get the word you know eight out of here and put it over here okay so what you can do is you get the substring of this the position here is as you can see at the I want to I want to get this whole string substring out of it and so it is like a zero one and two I'll stop at three okay how do you know what you stop well you stop it you if you know the size of the original string eat here right you get that there and then that would be the ending the stopping position and you will go from zero up to the size of this and we stop there right so we do that you're going to get the word you know at the at the end position of n of zero I put s here for substring starting from the zero position all the way to the size of the word because it would be a three right just like that so really you have to get the whole string here the size of the entire string subtract the size of this word eat so you get in this case you're going to get three anyway but you know it's the whole string would be six minus the size of this three and you get a three so that is just the stopping point okay that's how you get this number right here okay this number of comes from this entire string and then if I go back and then go and update the end of zero you still deal with the entire string here now it's going to be the end of zero the substring of again if you do a subtraction you're going to get starting from the third position and then all the way to the end all right so create the loop so for every i zero and that's then the length of the string power two okay the first position the string of the i position is equal to the string of the i plus the string of the last one which is the position of the last so that'll be the string the length minus one minus i okay that would be the last one in this case is the word the words um eight and then eight that is in that position uh not equal sorry minus minus and then we got that in there now last we placed the last position with the word eight so that would be str of the last position is the um string that length minus one minus i equal to the string first position which is i is substring starting from zero all the way to the size of the last string right which is the word eight so it would be the string that of the string that length minus one minus i and then get the size of that okay a lot of pretty long here um no that's not right right we want to subtract from here so what of this word was if it's like eating if it's eating right you want to subtract that many okay the whole thing here subtract this many to get the correct position okay so that means i have to subtract this whole thing i mean this whole thing here from the size of this whole thing which is in of zero s of zero so here really to do one more thing string of the i that length minus that yeah i think that's it okay let's see that works and then finally the string of the i position is going to be the string of the i okay that substring of the size of this last position because at this point we already swapped and we got the word eight okay so here on we're going to ignore the eight and we'll start from eating only right so how do you start from here is the size of this you can start at the end of the size of this so in this case it'll be the substring of the string at the i position maybe the last position minus i minus one minus i and then that length and then we go all the way to the end of that and we just leave it blank like that and that will give us the word eating okay let's see if this is true let's give it a shot and here we go you can see that it's working beautifully okay eating and that's work so that is you know a lot of typing a lot of word here but um at least you see that we did not create any additional variable to store another variable so thank you