# [9\. Palindrome Number](https://leetcode.com/problems/palindrome-number/) :::spoiler Solution ```cpp= class Solution { public: bool isPalindrome(int x) { if (x < 0) return false; if (x != 0 && x % 10 == 0) return false; int reverted = 0; while (x > reverted) { int digit = x % 10; x /= 10; reverted = reverted * 10 + digit; } return x == reverted || x == reverted / 10; } }; ``` - T: $O(N)$ - S: $O(1)$ :::
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up