Palindrome Number
Jan 4 '12
6687 / 16659
Determine whether an integer is a palindrome. Do this without extra space.
重来没有这么爽过!
class Solution { public: int reverse(int x) { int r = 0; while (x > 0) { r = 10 * r + x % 10; x /= 10; } return r; } bool isPalindrome(int x) { if (x < 0) return false; if (reverse(x) == x) return true; else return false; } };