题目:
算法思想:左加右减,上加下减
代码:
bool judgeCircle(string moves) {
int i = 0,j = 0;
for(int index = 0;index < moves.length();index++)
{
if(moves[index] == 'R')
i++;
else if(moves[index] == 'L')
i--;
else if(moves[index] == 'U')
j++;
else
j--;
}
if(i == 0 && j == 0)
return true;
return false;
}