Strobogrammatic Number
Thoughts
Code
class Solution {
public boolean isStrobogrammatic(String num) {
for (int l = 0, r = num.length() - 1; l <= r; l++, r--) {
char c1 = num.charAt(l), c2 = num.charAt(r);
if (c1 == c2 && "180".contains(c1 + "") || c1 == '6' && c2 == '9' || c1 == '9' && c2 == '6') {
continue;
}
return false;
}
return true;
}
}Analysis
Last updated