leetcode657

水题没什么好说的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Solution {
public boolean judgeCircle(String moves) {
int z = 0;
int s = 0;
for(int i=0;i<moves.length();i++){
switch (moves.charAt(i)){
case 'R':z--;break;
case 'L': z++;break;
case 'U': s--;break;
case 'D': s++;break;
}
}
if (s==0 && z==0) return true;
return false;
}
}