246. Strobogrammatic Number
Input: "69"
Output: trueInput: "88"
Output: trueInput: "962"
Output: falseclass Solution {
// ask if 00 is a valid strobogrammatic number! Here is true!
public boolean isStrobogrammatic(String num) {
for(int i = 0, j = num.length() -1; i <= j; i++, j--){
if(!"00 11 696 88".contains(num.charAt(i) + "" + num.charAt(j)))
return false;
}
return true;
}
}Last updated
Was this helpful?