Determine whether an integer reads the same forward and backward without converting it to a string if possible.
Given an integer x, return true if x is a palindrome, and false otherwise.
An integer is a palindrome when it reads the same from left to right and from right to left.
You should be careful about negative numbers and numbers ending in 0.
Write a function that checks whether the decimal representation of x is symmetric.
x.true if x is a palindrome, otherwise return false.Example 1
Input
x = 121
Output
true
Explanation
The number reads the same forward and backward.
Example 2
Input
x = -121
Output
false
Explanation
From left to right it is -121, but from right to left it would be 121-.
Example 3
Input
x = 10
Output
false
Explanation
The reversed form would be 01, which is not the same as 10.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.