Robot
489. Robot Room Cleaner
Given a robot cleaner in a room modeled as a grid by using 4 APIs
Backtrack
O (4 ^ (n-m)), n is # of grid, m is # of blocks. Every grid can chose 4 directions
657. Robot Return to Origin
There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves.
The move sequence is represented by a string, and the character moves[i] represents its ith move. Valid moves are R (right), L (left), U (up), and D (down).
874. Walking Robot Simulation
A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands:
-2
: turn left 90 degrees-1
: turn right 90 degrees1 <= x <= 9
: move forwardx
units
Return the square of the maximum Euclidean distance that the robot will be from the origin.
1041. Robot Bounded In Circle
On an infinite plane, a robot initially stands at (0, 0)
and faces north. The robot can receive one of three instructions:
"G"
: go straight 1 unit;"L"
: turn 90 degrees to the left;"R"
: turn 90 degress to the right.
The robot performs the instructions
given in order, and repeats them forever.
Return true
if and only if there exists a circle in the plane such that the robot never leaves the circle.
It can be a cycle iff 1. It comes back to the starting point 2. It is not toward to starting position (North)
Last updated
Was this helpful?