Skip to content

Commit 9845f6f

Browse files
authored
Update Strobogrammatic Number.java
1 parent de0a584 commit 9845f6f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Easy/Strobogrammatic Number.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ class Solution {
22
public boolean isStrobogrammatic(String num) {
33
StringBuilder sb = new StringBuilder();
44
for (char c : num.toCharArray()) {
5-
if (c == '0' || c == '1' || c == '8') {
6-
sb.append(c);
7-
}
8-
else if (c == '6' || c == '9') {
5+
if (c == '6' || c == '9') {
96
sb.append(c == '6' ? '9' : '6');
10-
}
11-
else {
7+
} else if (c == '0' || c == '8' || c == '1') {
8+
sb.append(c);
9+
} else {
1210
return false;
1311
}
1412
}

0 commit comments

Comments
 (0)