 What's up guys, my name is Michael and welcome to my YouTube channel today We are going to go over this problem called get value get no value from Get no value. Okay. So basically we have a link list and we have a position from the tail right and From this tail we want to get the The number at the desired position. So here we have three two one zero and now we want to get the number at Three two one zero. We want to get the position from the tail. So in this case, we have three two one zero If I get the position of two from the tail, it would be Zero one two So the value two is at the desired position two here. So zero one two. So we're starting the cow backwards is at Position zero then one and two then three Okay, so I'm gonna use it. I did I solved this problem differently than how other people solved it So I'll show you guys what I did recursively So I actually create a helper method and passed by Reference for this integer position from tail because I wanted to modify this But basically I had three. Let's say we have three and two and one And this goes in all Right, so I what I did was I recursively called and Kept going to the next node. So three and two then one then null Once I was here The stack trace is gonna go back right the stack trace whenever you recursively call a function It goes back to the previous thing. So what I did was every time I went back by one I'm gonna subtract one from the position from back position From So we're given like this funk in this method position from tail, right? So every time I jump back. I just subtracted one every time after the recursive call and then So like if we had like, I don't know three two one null, right? Then after this recursive call it jumps back. I'm gonna subtract one from position from back Right, so let's say I was at like, let's say I wanted a position two right here three right position two so Position two started from two. So I Keep going to the right and When I get back to here when the stock call gets traced back. I subtract one. So then this is gonna be at one And I subtract one by one again. So it'll be at zero Wait, no first first. It's an all right. I Subtract for two minus one will be Which is one so when it returns back, I'm gonna have two minus one. So I'll have one then when the stack trace goes back we'll have one minus one we gets to zero and then Yeah, and then Wait, I think I think it's like When the null goes back to two one and then after this point, I Think it goes back and then we have two minus one minus one Well, which we get to zero and then we just returned this to Okay, so like for me, I did like less than zero, but After the recursive call goes back and go something like that. Okay, so I'll show you guys what the code I mean Okay, so So you have get node I had a helper function that has the exact same method signature except I have Pass by reference because I want to modify this position from tail number integer Because if I don't have this what happens is that like it would It would It wouldn't get changed a position from tail Position that I pass it over and over again. I wouldn't get changed. So that's why I have I pass it by reference Here's what I do if the list is not equal to null pointer I'm going to recursively call this method and keep going next over and over again Right. Keep going next keep going next keep going next. All right Once I reach null pointer, I'm gonna return zero. Okay, so if I've reached a null pointer where I reached and I'm gonna return zero Okay, if my return value is not is not equal to zero then I just return it whatever return value I had But um, yeah, otherwise what I'm gonna do is I'm just gonna subtract one from the position from the tail So if I'm at like, I don't know if I'm all the way on the back, right? I'm gonna subtract one from position tails. So we'll be one and then yeah then if it's less than zero if my position from tail is less than zero that means I'm at the The actual node that the node data that I want to return, right? So at this point I return the list's data Okay But if it's not then it'll go back up to the top and recursively call And I'm just gonna keep tracking one from position from tail and then yeah if it is if it is less than equal less than zero then I return the data and then it goes back to this return function and If it's not equal to zero either my return value is equal to zero. I'm just gonna return Returned. Okay. So yeah, I just returned that number again. So yeah That's basically just the month this Function call I have passed in help also and I pass in position and I pass in the list. So yeah But yeah, that's the gist of how I did this function call. You don't have to do it the way I did Basically, I'm just going next next next and then every time I go backwards from the stack I just subtract one from the position of the back Until I reach to the node that I want to get and then at that point I just return it But yeah, I hope you guys know this video right come subscribe. I'll check you guys later. Peace