class Solution {
public:
    bool isPalindrome(int x) {
        if (x < 0) return false;
        int div = 1;
        while (x / div >= 10) div *= 10;
        while (x > 0) {
            int left = x / div;
            int right = x % 10;
            if (left != right) return false;
            x = (x % div) / 10;
            div /= 100;
        }
        return true;
    }
};

相关文章:

  • 2021-08-16
  • 2021-04-11
  • 2021-12-12
  • 2021-09-22
  • 2021-04-02
  • 2021-07-24
猜你喜欢
  • 2022-01-23
相关资源
相似解决方案