class Solution {
public:
bool judgeCircle(string moves) {
char action[4] = {'L','U','R','D'};
int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};
int x = 0,y = 0;
for(int i = 0;i<moves.size();i++)
{
char c = moves[i];
for(int j = 0;j<sizeof(action);j++)
{
if(c == action[j])
{
x+=dx[j];
y+=dy[j];
break;
}
}
}
return !x&&!y;
}
};