Determine whether an integer is a palindrome. Do this without extra space.
1 class Solution { 2 public: 3 bool isPalindrome(int x) { 4 if(x < 0){ 5 return false; 6 } 7 if(x == 0){ 8 return true; 9 } 10 11 int temp = x; 12 int y = 0; 13 int j = 0; 14 while(x) 15 { 16 // y = y*10 + x%10; 17 j = x%10; 18 x = x/10; 19 y = y*10 + j; 20 21 22 } 23 24 if(y == temp){ 25 return true; 26 }else{ 27 return false; 28 } 29 } 30 };