Palindrome Number

Palindrome Number

Total Accepted: 95552 Total Submissions: 318732 Difficulty: Easy

Determine whether an integer is a palindrome. Do this without extra space.

class Solution {
public:
    bool isPalindrome(int x) {
        int y   = 0;
        int tmp = x;
        while(tmp){
            y   = y*10+tmp%10;
            tmp = tmp/10;
        }
        
        return x>=0 && y==x ;
    }
};
原文地址:https://www.cnblogs.com/zengzy/p/5057552.html