腾讯五十题 No.6 回文数

题目链接
easy题,没有奇奇怪怪的条件限制

class Solution{
    public boolean isPalindrome(int x){
        if(x<0) return false;
        //if(x<10) return true;
        int num = x;
        int ans = 0;
        while(x != 0){
            ans =ans*10 + x%10;
            x = x/10;
        }
        return ans == num;
    }
}

posted @ 2022-02-05 11:19  蹇爱黄  阅读(24)  评论(0)    收藏  举报