Determine whether an integer is a palindrome. Do this without extra space.
题目含义:不要使用额外空间,判断整数是否为回文
1 public boolean isPalindrome(int x) { 2 int rev = 0; 3 int y=x; 4 while (y>0){ 5 rev = rev*10 + y%10; 6 y = y/10; 7 } 8 return x==rev; 9 }
Determine whether an integer is a palindrome. Do this without extra space.
题目含义:不要使用额外空间,判断整数是否为回文
1 public boolean isPalindrome(int x) { 2 int rev = 0; 3 int y=x; 4 while (y>0){ 5 rev = rev*10 + y%10; 6 y = y/10; 7 } 8 return x==rev; 9 }