class Solution {
public:
bool judgeCircle(string moves) {
int dx = 0, dy = 0;
for(int i = 0; i < moves.length(); i++) {
if (moves[i] == 'U') {
dy++;
} else if (moves[i] == 'D') {
dy--;
} else if (moves[i] == 'R') {
dx++;
} else if (moves[i] == 'L') {
dx--;
}
}
return dx == 0 && dy == 0 ? true : false;
}
};