#K82807. Return to Origin
Return to Origin
Return to Origin
You are given a sequence of movements represented by a string. Each character in the string is one of U, D, L, and R representing upward, downward, leftward, and rightward moves respectively.
Your task is to determine whether these movements return you to the origin point \( (0, 0) \). The position is updated as follows:
- \( U \): Increase the y-coordinate by 1.
- \( D \): Decrease the y-coordinate by 1.
- \( L \): Decrease the x-coordinate by 1.
- \( R \): Increase the x-coordinate by 1.
If after processing the entire string the final position is \( (0, 0) \), then output True
; otherwise, output False
.
inputFormat
The input consists of a single line containing the string of movements. The string may be empty.
outputFormat
Output a single line: True
if the sequence returns you to the origin (0, 0), otherwise False
.
UDLR
True