class Solution { public boolean judgeCircle(String moves) { int lr = 0; int ud = 0; for (char c: moves.toCharArray()) { if ('U' == c) { ud += 1; continue; } if ('D' == c) { ud -= 1; continue; } if ('R' == c) { lr += 1; continue; } if ('L' == c) { lr -= 1; continue; } } return ud == 0 && lr == 0; } }