 Hi, welcome back. This is Christian. In this video, we're going to look at how you delete a current node between a list of nodes. So we learned how to delete a head node in the tail node in the previous video. This time, how do you remove the node between two nodes? So it's a little bit tricky, but it should not be that difficult. But again, as you do this, you also want to make sure that you can also check to see if the head is indeed the same as the tail. In that case, it would be in a single node. If that's the case, then we have this case before. So let's see how this is done. So the idea is basically we use two pointers. One is to the current node. Again, I showed you before that you can actually complete this in one node too, which is OK. As long as you go in dot next dot next, as opposed to the current node. But this time, I'm going to go and use back to the current node in the previous node and see how that's done. OK, so all I have to do is basically bypass this node to the next node. And then once you bypass that node, this will be collected by the trash collector. So if you don't use it at all, then it'll be removed from memory. So that's the idea. All right, so let's go and see how this is done. So back in here, some beautiful pets, the emojis over here on the right side. Now we're going to remove, for example, let's say, from the rooster from the list. So let's go right on here. And this time, we already have the function to remove the head in the tail. So if we check to see if that is indeed the tail or the tail, then we'll just call this function and take advantage of these two functions. So we have to do it over again. OK, so I mean, we'll see in a minute. So we'll do here, remove. What should we call this one? Remove item. I guess then we find a key and then the item to be removed. So as usual, if self-dehead is equal to none, then nothing to do. Also, for a current node is equal to the self-dehead. And then the previous node is indeed none. And then while the current node is not equal to none, that means we haven't reached the tail yet. Then we go ahead and do the following. So again, right before you forget, update the two nodes. OK, we do the current node. And then the current node is equal to its next node. OK, make sure you do that before you forget. Now up here, so we're going to check the value. If the current node, the item is indeed the key. We found it right. And then we have to check to see if the key is the current node or not. I mean, the head node or not, right? If the head node, then we pass it to the function, remove head. Yeah, remove the head. If it's the tail, then we pass it to the remove tail to handle that. So we don't have to do all this this over again. OK, otherwise, we just do and we insert a removal in between. So we'll say if the current node is equal to the head, if that's the case, then we'll just go to self-remove head. OK, because that is only the item, right? It's the matching one. Else, if the current node is the tail, and we just call it a remove tail. Otherwise, it must be in between. OK, so if it's in between, like for example, the rooster, all we have to do is we're going to remove this node by pointing the previous next pointer to the current next pointer, so we'll bypass the current node. And that's one simple operation. So we'll do previous, that next is assigned to the current node, that next. And that's it. That's all you have to do here. And finally, out of this loop here of the if block, we also want to say size is equal to minus 1. We remove 1. So again, just to return here, we are done. OK, and I think that's it. So let's give it a try. Actually, you know what? I did not use the item here. Yeah, we don't need the item here. We just the keys for it. We're not removing the additional item. We just the key to match the key here. So I'll just notice that we didn't use that one. So let's save it again. And let's try if this thing works. Now I'm going to copy this again one more time. Now this is going really huge now. It's OK. I will do a few print statements down here. So we have a couple of lines, two extra lines. All right, so this time we've got to remove the rooster. So sorry, rooster. I'm going to remove you from the list. So we move item, and the item is going to be the rooster. So that's that one. And then after we've moved the rooster, we go into remove the pig. So it's going to be the last, right? So we've moved the pig as well. Let's remove this here. I'm going to duplicate this, but we'll do three of them. So the rooster is going to be removed. And then we have dog, cat, and pig. So we remove the pig. And then after that, we just have the dog and the cat. So let's move the head, which is the dog. So we copy the dog. And finally, if it's correct, our last list should be just the cat all by itself. All right, so let's put here. Let's put here remove item and cross your fingers. Let's clear the list first. There we go. Boom, oh, error, yay. All right, so remove tail. Did that mean we moved tail? OK, I probably have a typo. I can see it, remove. Where is it? Right here. There we go. I need you to tell me. All right, well, I'm on time. Clear my console. And here we go. OK, so it seems to be successful, right? So here's the remove. We remove the rooster. And then we remove the pig. And we remove the dog. So now we have only just the cat. I mean, it'll be confusing. I apologize, but let's do this. Let's do one at a time, OK? I know it's probably easier that way. I shouldn't. It's hard to see. One more time. One step at a time. So here we go. Is remove the right here, right? Remove the pig first. So now it's no pig. We remove the dog and then no dog, just a cat left. OK, if you do one more time, if you remove that, you know, if you remove one more. So the list is empty. Why not, right? That's so much fun here. OK, so I'm going to move the cat. OK, and then if that is removed, then our list is completely empty at this point, as you can see over here. So we are now done. All right, so you can see that we've done a lot of operations here. We learned how to create a node, you know, add to the end of the list, add to the front, print in order, from reverse using recursion. We search a key. We turn that node to do some operations. Be careful because if you call this key here, you do some manipulation to the current node. You may break the chain because this is a reference type. OK, so be careful with that. We insert a note after a particular key. It's before a key. We did a remove of the head and the tail. And we also did every move an item in between. And that is almost out of the operation. So I hope this is helpful. And let's see if I have any more things to add. All right, so I guess in the next last video, we're going to create two functions to update a list for replacement and also how to search a list using deposition. Instead of the actual image or the item, we can search by index. And of course, by doing that, we can know by the size of the array on the list. So I'll see you in the next video.