Palindrome Number
Easy Math & Geometry AI round
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
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.
Your first AI round is free.
Watch the explanation
More Math & Geometry
- Rotate ImageAI round · Medium
- Roman to IntegerAI round · Easy
- Reverse IntegerMedium
- Count PrimesMedium
- Integer to RomanMedium