#K39272. Return to Origin
Return to Origin
Return to Origin
Given a sequence of moves represented by a string consisting of the characters 'L', 'R', 'U', and 'D', determine whether a character starting at the origin \( (0,0) \) returns to the origin after executing all the moves. Each character in the string corresponds to a single move: 'L' for left, 'R' for right, 'U' for up, and 'D' for down.
Example: For an input of "UDLR", the moves bring the character back to \( (0,0) \), so the output should be "Yes".
inputFormat
The input is a single line containing a non-empty string that represents the sequence of moves.
Note: The string will only consist of the characters 'L', 'R', 'U', and 'D'.
outputFormat
Output a single string "Yes" if after performing all the moves the character returns to the origin \( (0,0) \); otherwise, output "No".
## sampleUDLR
Yes