#K15211. Robot Return to Origin
Robot Return to Origin
Robot Return to Origin
A robot is initially positioned at the origin (0,0) on a 2D plane. It can move up, down, left, or right, which are represented by the characters 'U', 'D', 'L', and 'R', respectively. After executing a sequence of moves described by a string, your task is to determine whether the robot returns to its starting point.
Mathematically, the robot returns to the origin if its final coordinates \( (x, y) \) satisfy \( x = 0 \) and \( y = 0 \). For instance, if the moves string is "UDLR", the moves cancel out resulting in \( x = 0 \) and \( y = 0 \), so it returns to the origin.
inputFormat
The input consists of a single line, which is a string describing the moves. Each character in the string is one of 'U', 'D', 'L', or 'R'.
outputFormat
Output a single line containing "YES" if the robot returns to the origin, and "NO" otherwise.
## sampleUDLR
YES