Practice Walking Robot Simulation
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 begins at (0, 0) facing north, the positive y direction. Command -2 turns left 90 degrees, -1 turns right 90 degrees, and an integer from 1 through 9 moves that many unit steps forward. Stop the current move before entering an obstacle and then process the next command. An obstacle at the origin does not prevent departure, but prevents a later return. Return the maximum x^2 + y^2 reached anywhere along the path.
Source: Walking Robot Simulation on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
commands = [4,-1,3], obstacles = []
25
# Example 2
commands = [4,-1,4,-2,4], obstacles = [[2,4]]
65
# Example 3
commands = [6,-1,-1,6], obstacles = [[0,0]]
36
Constraints
Related LeetCode Problems
Practice more problems similar to Walking Robot Simulation.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.