#C3044. Return to Origin
Return to Origin
Return to Origin
You are given a string consisting of the characters L
, R
, U
, and D
. Each character moves the robot one unit in the corresponding direction: left, right, up, and down respectively.
The robot starts at the origin (0, 0)
. After executing all moves, your task is to determine if the robot returns to its starting position. Mathematically, if the final coordinates of the robot are \( (x, y) \), then the robot has returned to the origin if and only if \( x = 0 \) and \( y = 0 \).
Input constraint: The instruction string will only contain the characters L
, R
, U
, and D
.
inputFormat
A single string representing the sequence of moves provided via standard input (stdin). For example: "LRUD".
outputFormat
Output a single line: True
if the robot returns to the origin after following the moves, otherwise output False
.## sample
LR
True