思路:略,很简单
java版本
class Solution { public boolean judgeCircle(String moves) { int x = 0; int y = 0; char[] movestmp = moves.toCharArray(); for(char key : movestmp) { switch (key) { case 'U': { y += 1; break; } case 'D': { y--; break; } case 'L': { x--; break; } case 'R': { x++; break; } default: break; } } return x == 0 && y == 0; }}
----------------