Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.
思路:将原数字从各位数字开始拆分成两部分,最终比较两个数字的大小即可。
public boolean isPalindromeII(int x) { if(x < 0 || x > 0 && x % 10 == 0) return false; int y = 0; while(x > y) { y = y * 10 + x % 10; x = x /10; } return x == y || x == y/10; }