Palindrome Number
Easy Math & Geometry
x is a whole number. It is a palindrome when its digits read the same from right to left as from left to right.
Return true when x is a palindrome and false when it is not. A negative number never is, as its minus sign has no partner at the other end.
Try to answer by working with the number's digits, without writing x out as a string.
Example 1
Input: x = 4554
Output: true
Read from right to left, 4554 is 4, 5, 5, 4: the same digits in the same order.
Example 2
Input: x = -77
Output: false
Example 3
Input: x = 1200
Output: false
Constraints
-2³¹ ≤ x ≤ 2³¹ - 1
Solve it here
Write it in Python, Java or C++, run it on your own cases, and submit against hidden tests.
Practice this in an AI round
30 minutes on this problem with an AI agent beside your code, then a report on your solution and how you used the agent.
See the AI roundWatch the explanation
More Math & Geometry
- Rotate ImageAI round · Medium
- Roman to IntegerAI round · Easy
- Count PrimesAI round · Medium
- Reverse IntegerMedium
- Integer to RomanMedium