 What's up guys, my name's Michael and welcome to my YouTube channel. Today we're going to do another lead code challenge called middle of the link list. You're given a non-empty, singly link list with a node head and with a head node of head. Return the middle node of the link list. That's basically all you have to do. You're just translating this to code basically. So what I did was I basically just went through every single add a current pointer that points to the head and I'm going to go through all the values in the link list until I reach the end. Every time we go through a value I'm going to increase my length of, I keep track of the length of the link list. Once I get the length of the link list I'm going to divide it by two. My length is now I'm going to divide the length by two so that's going to get the middle. Then once I have the middle I'm going to start my, I'm going to go back to, I'm going to have another pointer pointing to the beginning of the link list again and I'm going to keep going with start. The start is my, no, so beginning is going to point to the head of the link list again and then start is going to be the count of my current position I'm at in the link list. I'm basically going to keep going until I reach the middle, middle value of my link list and then I return it. So that's my solution. There's actually a better solution that allows you to only have to go through the link list once and you don't have to do it twice. Okay, so there's a better way to do it. This is called slow fast pointer and I'm going to actually copy the solution with you guys just to make sure that you guys are also doing this. I'm doing this as well. We're going to keep two, we're basically going to keep two, two pointers called slow point it to head and links this node fast point it to head and what we're going to do is where we are going to have this should, why is he doing this? Okay, whatever. What we're going to do is we are going to check fast is not equal to null and fast next is not equal not equal to null. So this fast node is going to go faster than our slow node. It's going to go twice as fast. So rather than jumping once, once per every iteration, it's going to jump twice. So it's going to jump two times. Okay, so it's going to go next and the next. So that's what this fast is. It's going to check if the fast is null. There's a current. If the current node is null, then I mean you can't go next next, right? Or it's next is no. Make sure next is not null and it's currently is not null. What I'm going to do is I'm going to go to slow is going to point to next. I'm going to go to next of slow, and I'm going to jump twice. So for fast, I'm going to jump fast is going to get to a next next. So fast is going to jump twice. And slow is going to jump once when we go to the end of the array. Basically, fast is going to because fast goes twice, the speed of slow fast is going to slow fast is going to reach the end first. And then our slow is going to be reached at the middle. So because of that, we're going to return slow, because fast is going two times and slows only going once. You guys get it? We had to have this. Yeah, so that that's it then it got zero milliseconds. Yeah, so that that's how the solution goes. The reason why we have fast is not equal to null. We have to check if because we're going twice, we're going two nodes ahead, we have to check if the current value of fast is not null, and we have to check the next is not null. Otherwise, if the next is null, then you can't jump twice. Okay, so that's what this while loop is. Hope you guys enjoyed this tutorial. Rate, com, subscribe, and I'll get check you guys later. Peace.