accountforcheating's blog

By accountforcheating, history, 4 years ago, In English

A robot stands at (0,0), with its back against an infinite wall defined by y = 0. It can receive one of three instructions: 1. “G”: go straight 1 unit 2. “L”: turn 90 degrees to the left 3. “R”: turn 90 degrees to the right

The robot performs the instructions given in order, and repeats them till it encounters the wall again. Return true if and only if a final position exists.

Note: 1. 1 <= instructions.length <= 100 2. instructions[i] is in {‘G’, ‘L’, ‘R’}

Output Format: "0" for false (without "") "1" for true (without "") Sample Input: GLR Sample Output: 0

Full text and comments »