Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place.
The move sequence is represented by a string. And each move is represent by a character. The valid robot moves are
U (Up) and
D (down). The output should be true or false representing whether the robot makes a circle.
Related Topics: String
中文翻译版: 657. 判断路线成圈
根据题目描述，可以设定一个二维坐标 (x, y)，根据指令做相应的改变：
- Right: x = x + 1
- Left: x = x - 1
- Up: y = y + 1
- Down: y = y - 1
最后判断二维坐标 (x, y) 是否为原点 (0, 0) 即可。实现代码如下：