[leetcode] Palindrome Number

来源:互联网 发布:新东方英语网络视频 编辑:程序博客网 时间:2024/05/16 07:49

From : https://leetcode.com/problems/palindrome-number/

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

class Solution {public:    bool isPalindrome(int x) {        if(x<0) return false;        unsigned int t=x, low=1, high=1;        while(t/10) { high *= 10; t /= 10; }        while(low < high) {            if(x/high%10 != x/low%10) return false;            low *= 10;            high /= 10;        }        return true;    }};


0 0