Practice Robot Bounded In Circle
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
A robot starts at (0, 0) facing north, the positive y direction. G moves it one unit forward, L turns it 90 degrees counterclockwise and R turns it 90 degrees clockwise. The robot repeats instructions forever. Return whether its entire path stays within some finite circle.
Source: Robot Bounded In Circle on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
instructions = "GGLLGG"
Output
true
# Example 2
Input
instructions = "GG"
Output
false
# Example 3
Input
instructions = "GL"
Output
true
Constraints
1 <= instructions.length <= 100
instructions[i] is 'G', 'L' or, 'R'.
Related LeetCode Problems
Practice more problems similar to Robot Bounded In Circle.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.