Loading

9. [栈]回文数

9. 回文数

// 执行耗时:9 ms,击败了99.19% 的Java用户
// 内存消耗:38.2 MB,击败了62.03% 的Java用户

class Solution {
    public boolean isPalindrome(int x) {
        if (x < 0){
            return false;
        }
        int res = 0, raw_x = x;
        while (raw_x != 0){
            res = res * 10 + raw_x % 10;
            raw_x /= 10;
        }
        return x == res;
    }
}
posted @ 2020-10-24 10:40  上海井盖王  阅读(112)  评论(0)    收藏  举报