246.中心对称数
class Solution {public boolean isStrobogrammatic(String num) {HashMap map = new HashMap();map.put('6','9');map.put('8','8');map.put('1','1');map.put('9','6');map.put('0','0');int n = num.length();for(int i = 0; i < n ;i++){//如果字符串中包含不可翻转的字符,返回falseif(map.get(num.charAt(i)) == null){return false;}//从后向前遍历字符串,判断其是否等于翻转后的字符if(num.charAt(n - i - 1) != (char)map.get(num.charAt(i))){return false;}}return true;}
}