Skip to content

Commit 1b7a1fd

Browse files
refactor 657
1 parent 36183c8 commit 1b7a1fd

File tree

1 file changed

+15
-13
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+15
-13
lines changed

src/main/java/com/fishercoder/solutions/_657.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,22 @@ The valid robot moves are R (Right), L (Left), U (Up) and D (down).
2222
*/
2323

2424
public class _657 {
25-
public boolean judgeCircle(String moves) {
26-
int hori = 0;
27-
int verti = 0;
28-
for (char c : moves.toCharArray()) {
29-
if (c == 'U') {
30-
verti++;
31-
} else if (c == 'D') {
32-
verti--;
33-
} else if (c == 'L') {
34-
hori--;
35-
} else if (c == 'R') {
36-
hori++;
25+
public static class Solution1 {
26+
public boolean judgeCircle(String moves) {
27+
int hori = 0;
28+
int verti = 0;
29+
for (char c : moves.toCharArray()) {
30+
if (c == 'U') {
31+
verti++;
32+
} else if (c == 'D') {
33+
verti--;
34+
} else if (c == 'L') {
35+
hori--;
36+
} else if (c == 'R') {
37+
hori++;
38+
}
3739
}
40+
return verti == 0 && hori == 0;
3841
}
39-
return verti == 0 && hori == 0;
4042
}
4143
}

0 commit comments

Comments
 (0)