 What's up guys my is Michael and welcome to my YouTube channel today. We're gonna do another league code challenge We're gonna do robot returns the origin So basically you have a robot starting a position zero zero you're given a set of moves and then you got it Excuse me. You got a judge if the robot ends up back at zero zero after it completes its moves So it's pretty basic The move sequence is represented by a string and the character moves Represents the ith moves right so if the valid moves are ours right L is left use up d is down If the robot returns to the origin after finishes all its move return true. Otherwise return false Okay, so in this case you In this case You in this case. There's a there's a there's a string Ui a Ud Ud that means it went up and then it went down Yeah, I went up and then went it down and because the robots moves up once and then it moves down once all the moves Have the same magnitude so it ends up at the position where it started, which is zero zero so returns true Over here. We have the moves left once then moves left again It's as false to remove the robot moves left twice It ends up at two moves to the left instead of the origin return false because it is not at the origin after It's number moves. So guys basically this is pretty basic. I will you okay, I Basically, I'm going to tell you guys that you should Give you some time to do this I'm gonna give you some time to do this and if you can't think of how to do this come back to me and then Yeah, then I'll explain the solution. Okay guys, so You you have to Okay, so I'm gonna explain the solution now First we have need to have an X position and Y position to represent the current state of The robot Okay Then we're just gonna go through use a for loop for every single move We're gonna go through every character in this string now if Now we're gonna do is a Yeah, okay, we're gonna use now we're gonna use multiple if statements We're gonna get the whatever character added at the position right if it's whoa, what was this? Okay, whatever if If it's a you then that means I'm gonna increase my Let's see you is up right so increase. I'm gonna increase my Y position by one. So if it's you I'm gonna increase Y position. Oh my gosh Increase Y position by one Now I'm gonna do else if if moves at I is equal to Let's see if it's a D moves down. I decrease my Y position and else if Yeah, okay, then I'm gonna have another if statement moves now if it's a Left move I'll decrease my X position And then else if moves Right, I'll increase my X position then after all my moves are made This is basically just going to You know go through all the moves all the moves I made I'm gonna return whether X position is equal to zero and Wide position is equal to zero. So ideally this should work and it works That's that's basically the solution. I mean, there's nothing much to it. Let me see what they have Okay, yeah, so yeah, it's they basically did the exact same thing as what I did, but yeah, right calm subscribe. I'll check you guys like