https://leetcode.com/problems/palindrome-number/
1. Revert half of the number
//12 ms 5.9 MBclass Solution {public:bool isPalindrome(int x) {if(x < 0)return false;if(x == 0)return true;//x > 0long long int curr = 0; //we have a test case 2147483647, over the limit of intlong long int orig = x; //so apply long long intwhile(x != 0){curr = curr * 10 + (x % 10);x /= 10;}if(curr != orig)return false;elsereturn true;}};
Time complexity:
Space complexity: O(1)
