#C10113. Return to Origin
Return to Origin
Return to Origin
Given a string s
consisting only of the characters 'U', 'D', 'L', and 'R', determine whether the sequence of moves returns to the origin \((0,0)\). Each character in the string represents a movement: 'U' for up, 'D' for down, 'L' for left, and 'R' for right. The origin is defined by the coordinates \((0,0)\). If after performing all the moves the point is back at the origin, output "True"; otherwise, output "False".
Note: The input will be provided via standard input (stdin) and your output must be printed to standard output (stdout). Ensure your solution reads the entire input in one go.
inputFormat
The input consists of a single line containing a string s
composed only of the characters 'U', 'D', 'L', and 'R'. The string can be empty, which indicates no movement.
outputFormat
Print a single line containing True
if the moves result in the point returning to the origin \((0,0)\), otherwise print False
.
UDLR
True
</p>