Posts

Showing posts from October, 2021

LeetCode Problem 1041- Robot Bounded In Circle - Level - Medium

Image
LeetCode 1041 - Robot Bounded In a Circle Today we are going to look at another LeetCode problem  1041 robot bounded in a circle with difficulty level medium. Problem Statement : From given problem statement , Robot can perform certain given sets of instruction either G,R,L and corresponding action can be taken. After performing instruction if robot come back to original position (0,0) that means robot will stay in circle and will never leave it. Let's understand more in details about behaviour of robot. Robot is standing at position (0,0) coordinates and facing North.  G >> Move One Step Ahead. That mens increment Y coordinate by One. R >> Rotate Robot to 90 degree right but stay there. L >> Rotate robot on left with 90.  Let's understand this problem by example given in problem statement. Command : GGLLGG Step 1 : First robot gets input at GG which means robot will move 2 step ahead by incrementing Y coordinates. So current position of robot will be (X,Y)