class Solution {
public:
bool judgeCircle(string moves) {
int UD = 0 ,LR = 0;
for(char a:moves){
if (a=='U') {
UD++;
}else if (a=='D'){
UD--;
}else if (a=='L'){
LR++;
}else if (a=='R'){
LR--;
}
}
return (UD==0&&LR==0) ? 1:0;
}
};
Judge Route Circle
Copyright © 2017 Powered by LZH, Theme used GitHub CSS.