A robot starts at (0, 0) facing north on an infinite plane. It executes the characters of instructions in order, repeating the entire string forever.
Gmoves forward one unit in its current direction.Lturns left by 90 degrees without moving.Rturns right by 90 degrees without moving.
Return true if the robot stays within some fixed circle forever, and false if it travels arbitrarily far from the origin.
Example 1:
Input: instructions = "GR"
Output: trueExplanation: After four repetitions, the robot traces a unit square and returns to its starting position and direction. Repeating that square keeps it bounded.
Example 2:
Input: instructions = "GLGR"
Output: falseExplanation: Each repetition moves one unit north and one unit west, then restores the original northward direction. The robot keeps drifting away from the origin.
Example 3:
Input: instructions = "LR"
Output: trueExplanation: These instructions only turn the robot left and then right. It never moves from the origin.
Constraints:
1 <= instructions.length <= 100- Only
G,L, andRoccur.