class Solution {
public:
bool judgeCircle(string moves) {
int x = 0;
int y = 0;
for(auto c:moves){
if(c=='U'){
y++;
}
else if(c=='D'){
y--;
}
else if(c=='R'){
x++;
}
else if (c=='L'){
x--;
}
}
return (x==0 && y==0);
}
};
leetcode657 C++ 16ms 判断回环
转载于:https://www.cnblogs.com/theodoric008/p/9370942.html