public class Solution { public boolean isPalindrome(int x) { if(x < 0){ return false; } if(x < 10 ){ return true; } String xstr = String.valueOf(x); //System.out.println(xstr + " : " + xstr.length()); int tmp = 0; int len = xstr.length() - 1; int count = 1; while(len > 0){ count = count * 10; len--; } //System.out.println(" asdf" +count); int cmpX = x; while(x / 10 > 0){ tmp = tmp + (x % 10) * count; //System.out.println(tmp); count = count / 10; x = (x - x %10)/10; } tmp = tmp + x *count; if(tmp == cmpX){ return true; } return false; }}
Palindrome Number
,似乎不可以做成reverse integer ,不过提交通过了