#C6394. Robot Return to Origin
Robot Return to Origin
Robot Return to Origin
Given a string of commands where each command directs a robot's move ('U' for up, 'D' for down, 'L' for left, and 'R' for right), determine whether the robot returns to the origin \((0,0)\) after executing all the commands.
The robot starts at the origin \((0,0)\) and each command moves it exactly one unit in the corresponding direction. Output True
if after processing all commands the robot is back at the origin; otherwise, output False
.
inputFormat
The input consists of a single line containing a string of movement commands. The string may be empty.
outputFormat
Output a single line: True
if the robot returns to the origin, or False
otherwise.
UD
True