class Solution {
public boolean judgeCircle(String moves) {
int x=0,y=0;
for(int i=0;i<moves.length();i++){
if(moves.charAt(i)=='U') x++;
else if(moves.charAt(i)=='D') x--;
else if(moves.charAt(i)=='L') y++;
else if(moves.charAt(i)=='R') y--;
}
return x==0&y==0;
}
}
leetcode 657 Judge Route Circle
最新推荐文章于 2024-09-25 10:59:43 发布