A robot starts at (0, 0) on an infinite plane facing north. It understands three instructions: "G" moves one unit forward, "L" turns 90 degrees left and "R" turns 90 degrees right. The robot repeats the given instructions forever. Return true if there is a circle on the plane that the robot never leaves.
A robot starts at (0, 0) on an infinite plane facing north. It understands three instructions: "G" moves one unit forward, "L" turns 90 degrees left and "R" turns 90 degrees right. The robot repeats the given instructions forever. Return true if there is a circle on the plane that the robot never leaves.
Example 1:
Input: {"instructions":"GGLLGG"}
Output: true
Constraints:
1≤ instructions.length ≤100
instructions[i] is 'G', 'L' or 'R'.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"instructions":"GGLLGG"}
The robot starts at (0, 0) facing north. Run the 6 instructions once and see where it ends up and which way it faces.