#K15666. Robot Return to Origin
Robot Return to Origin
Robot Return to Origin
In this problem, you are given a string of commands where each character represents a move for a robot: 'U' (up), 'D' (down), 'L' (left), and 'R' (right). The robot starts at the origin ( (0,0) ) on a 2D plane. After executing all the commands, your task is to determine whether the robot returns to the origin. In other words, if the final coordinates ( (x,y) ) satisfy ( x = 0 ) and ( y = 0 ), then the robot is back at its starting point.
inputFormat
The input is read from standard input. The first line contains an integer ( T ) representing the number of test cases. Each of the following ( T ) lines contains a non-empty string comprised solely of the characters 'U', 'D', 'L', and 'R'.
outputFormat
For each test case, print "Yes" if the robot returns to the origin; otherwise, print "No". Each output should be on a new line.## sample
4
UD
LLRR
UUDD
LLRU
Yes
Yes
Yes
No
</p>