An integer is a palindrome when its decimal digits read the same from left to right as from right to left, like 5885 or 30903. Given an integer x, return true if it is a palindrome and false if it is not.
A minus sign counts as part of what you read, so no negative number is a palindrome: -44 read backwards is 44-.
For an extra challenge, answer without turning x into a string.
Example 1
Input: x = 12321
Output: true
The digits mirror around the middle 3.
Example 2
Input: x = -505
Output: false
Backwards it reads 505-, with the sign at the wrong end.
Example 3
Input: x = 4400
Output: false
Backwards the digits are 0044. A number never starts with zeros, so one that ends in 0 can only be a palindrome if it is 0 itself.
Constraints
-2³¹ <= x <= 2³¹ - 1A negative number can never match its own reverse, and neither can a positive number that ends in 0 (only 0 itself). For everything else, compare the digits from the outside in.
12321
true